Browse Source

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

lilei 1 năm trước cách đây
mục cha
commit
38bfcab53c

+ 45 - 4
src/api/promotion.js

@@ -69,7 +69,7 @@ export const getNewScopeSn = (params) => {
     method: 'get'
   })
 }
-// 规则保存
+// 规则保存/修改
 export const promotionSave = (params) => {
   return axios({
     url: '/promotion/rule/save',
@@ -77,10 +77,51 @@ export const promotionSave = (params) => {
     method: 'post'
   })
 }
-// 删除仓位
-export const warehouseLocDel = params => {
+// 删除规则列表
+export const promotionRulesDel = (params) => {
   return axios({
-    url: `/warehouseLoc/delete/${params.sn}`,
+    url: '/promotion/rule/delete',
+    data: params,
+    method: 'post'
+  })
+}
+// 提交
+export const promotionSubmit = (params) => {
+  return axios({
+    url: `/promotion/submit/${params.sn}`,
+    data: {},
+    method: 'get'
+  })
+}
+
+// 改变发布状态
+export const modifyEnabledFlag = (params) => {
+  return axios({
+    url: '/promotion/modifyEnabledFlag',
+    data: params,
+    method: 'post'
+  })
+}
+// 审核
+export const promotionAudit = (params) => {
+  return axios({
+    url: '/promotion/audit',
+    data: params,
+    method: 'post'
+  })
+}
+// 变更促销时间
+export const promotionDateModify = (params) => {
+  return axios({
+    url: '/promotion/promotionDateModify',
+    data: params,
+    method: 'post'
+  })
+}
+// 中止
+export const promotionIsOver = (params) => {
+  return axios({
+    url: `/promotion/isOver/${params.sn}`,
     data: {},
     method: 'get'
   })

+ 23 - 18
src/views/promotionRulesManagement/dealerPromotions/addModal.vue

@@ -19,6 +19,9 @@
         <a-form-model-item label="促销名称" prop="title">
           <a-input id="promotionList-promotionName" v-model.trim="form.title" allowClear placeholder="请输入促销名称(最多30个字符)" :maxLength="30"></a-input>
         </a-form-model-item>
+        <a-form-model-item label="促销简称" prop="description">
+          <a-input id="promotionList-description" v-model.trim="form.description" allowClear placeholder="请输入促销简称(最多10个字符)" :maxLength="10"></a-input>
+        </a-form-model-item>
         <a-form-model-item label="促销时间" prop="activeDate">
           <a-range-picker
             style="width:100%"
@@ -30,7 +33,7 @@
             @change="onChangeDate"></a-range-picker>
         </a-form-model-item>
         <a-form-model-item label="费用所属部门" prop="expenseDepartmentSn">
-           <department style="width: 100%;" @change="departementChange" id="promotionList-basicInfo-activeDate" v-model="form.expenseDepartmentSn"></department>
+          <department style="width: 100%;" @change="departementChange" id="promotionList-basicInfo-activeDate" v-model="form.expenseDepartmentSn"></department>
         </a-form-model-item>
         <a-form-model-item label="参与客户" prop="dealerSnList">
           <a-row :gutter="15">
@@ -49,12 +52,12 @@
             </a-col>
           </a-row>
         </a-form-model-item>
-        <a-form-model-item label="促销描述" prop="description">
+        <a-form-model-item label="促销描述" prop="content">
           <a-textarea
-            id="promotionList"
+            id="promotionList-content"
             :maxLength="500"
             :rows="5"
-            v-model="form.description"
+            v-model="form.content"
             placeholder="请输入促销描述"
             allowClear />
         </a-form-model-item>
@@ -102,7 +105,7 @@ import department from '@/views/expenseManagement/expenseReimbursement/departmen
 import warehouse from '@/views/common/chooseWarehouse.js'
 import moment from 'moment'
 import chooseDealer from '../promotionManagement/chooseDealer'
-import { dealerPromotionSave, dealerPromotionInfo,dealerPromotionEdit } from '@/api/promotion'
+import { dealerPromotionSave, dealerPromotionInfo, dealerPromotionEdit } from '@/api/promotion'
 export default {
   name: 'PromotionListBasicInfoModal',
   mixins: [commonMixin],
@@ -128,35 +131,37 @@ export default {
       form: {
         title: '',
         activeDate: undefined,
-        expenseDepartmentSn:undefined,//费用所属部门
-        description: '', // 活动描述
-        attachmentList: '',//附件
-        dealerSnList:[]//参与客户
+        expenseDepartmentSn: undefined, // 费用所属部门
+        description: '', // 活动简称
+        content: '', // 活动描述
+        attachmentList: '', // 附件
+        dealerSnList: []// 参与客户
       },
       openDealerModal: false,
       chooseDealerList: [],
       attachList: [], // 附件
       dateFormat: 'YYYY-MM-DD',
       rules: {
-        title:[{ required: true, message: '请输入促销名称', trigger: 'blur' }],
-        activeDate:[{ required: true, message: '请选择促销时间', trigger: 'change' } ],
+        title: [{ required: true, message: '请输入促销名称', trigger: 'blur' }],
+        activeDate: [{ required: true, message: '请选择促销时间', trigger: 'change' } ],
         expenseDepartmentSn: [{ required: true, message: '请选择费用所属部门', trigger: 'change' }],
         dealerSnList: [{ required: true, message: '请选择参与客户', trigger: 'change' }],
-        description:[{ required: true, message: '请输入促销描述', trigger: 'blur' }]
+        description: [{ required: true, message: '请输入促销简称', trigger: 'blur' }],
+        content: [{ required: true, message: '请输入促销描述', trigger: 'blur' }]
       },
       attachAction: process.env.VUE_APP_API_BASE_URL + '/uploadGetFileInfo'
     }
   },
   methods: {
-    //选择活动时间
-    onChangeDate(date, dateString){
+    // 选择活动时间
+    onChangeDate (date, dateString) {
       this.form.activeDate = date
       if (dateString[0] != '' && dateString[1] != '') {
-       this.form.promotionDateStart = dateString[0] + ' 00:00:00'
+        this.form.promotionDateStart = dateString[0] + ' 00:00:00'
         this.form.promotionDateEnd = dateString[1] + ' 23:59:59'
       }
     },
-    //费用所属部门
+    // 费用所属部门
     departementChange () {
       this.$nextTick(() => {
         this.$refs.ruleForm.validateField('expenseDepartmentSn')
@@ -209,7 +214,7 @@ export default {
           form.attachmentList = _this.attachList
           delete form.activeDate
           _this.spinning = true
-          const ajaxName = _this.itemSn?dealerPromotionEdit:dealerPromotionSave
+          const ajaxName = _this.itemSn ? dealerPromotionEdit : dealerPromotionSave
           ajaxName(form).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
@@ -235,7 +240,7 @@ export default {
           this.chooseDealerList = data.dealerList
           data.dealerSnList = data.dealerSnList
           data.activeDate = [data.promotionDateStart, data.promotionDateEnd]
-          if(data.attachmentList){
+          if (data.attachmentList) {
             this.attachList = data.attachmentList
             this.$nextTick(() => {
               this.$refs.attachList.setFileList(this.attachList)

+ 14 - 13
src/views/promotionRulesManagement/dealerPromotions/chooseProductsModal.vue

@@ -62,7 +62,7 @@
             size="small"
             :rowKey="(record) => record.productSn"
             rowKeyName="productSn"
-            :row-selection="{ columnWidth: 40, getCheckboxProps:record =>({props: { disabled: this.chooseData && this.chooseData.indexOf(record.productSn) > -1 }}) }"
+            :row-selection="{ columnWidth: 40, getCheckboxProps:record =>({props: { disabled: this.chooseDataList && this.chooseDataList.indexOf(record.productSn) > -1 }}) }"
             @rowSelection="rowSelectionFun"
             :columns="columns"
             :data="loadData"
@@ -118,6 +118,7 @@ export default {
         productTypeSn2: '', //  产品二级分类
         productTypeSn3: '' //  产品三级分类
       },
+      chooseDataList: [],
       disabled: false, //  查询、重置按钮是否可操作
       loading: false, //  表格加载中
       columns: [
@@ -175,9 +176,8 @@ export default {
     //  重置
     resetSearchForm () {
       this.resetData()
-      console.log('1111111111111111')
       this.$refs.table.refresh()
-      // this.$refs.table.clearTable()
+      this.$refs.table.clearTable()
     },
     // 保存
     handleSave () {
@@ -204,18 +204,19 @@ export default {
     isShow (newValue, oldValue) {
       if (!newValue) {
         this.$emit('close')
-        this.resetSearchForm()
       } else {
         const _this = this
-        // let selectedRows = []
-        // const selectedRowKeys = []
-        // selectedRows = this.chooseData
-        // this.chooseData.map(item => {
-        //   selectedRowKeys.push(item.goodsSn)
-        // })
-        // this.$nextTick(() => { // 页面渲染完成后的回调
-        //   _this.$refs.table.setTableSelected(selectedRowKeys, selectedRows) // 设置表格选中项
-        // })
+        _this.resetSearchForm()
+        let selectedRows = []
+        const selectedRowKeys = []
+        selectedRows = this.chooseData
+        this.chooseData.map(item => {
+          selectedRowKeys.push(item.goodsSn)
+        })
+        this.chooseDataList = selectedRowKeys
+        this.$nextTick(() => { // 页面渲染完成后的回调
+          _this.$refs.table.setTableSelected(selectedRowKeys, selectedRows) // 设置表格选中项
+        })
       }
     }
   }

+ 46 - 23
src/views/promotionRulesManagement/dealerPromotions/detail.vue

@@ -39,9 +39,9 @@
       </a-card>
       <a-card size="small" title="规则设置" :bordered="false" class="pages-wrap">
         <div class="btnGroup" v-if="$route.query.type=='rule'">
-          <a-button type="primary" class="button-warning" @click="handleProduct" :disabled="disabled">买产品送产品</a-button>
-          <a-button style="margin:0 10px" type="primary" class="button-warn" @click="handleAmount" :disabled="disabled">买产品送采购额</a-button>
-          <a-button type="primary" @click="handleSpecialProduct" :disabled="disabled">特价产品</a-button>
+          <a-button type="primary" class="button-warning" @click="openBtnModal('SendProducts')" :disabled="disabled">买产品送产品</a-button>
+          <a-button style="margin:0 10px" type="primary" class="button-warn" @click="openBtnModal('SendAmount')" :disabled="disabled">买产品送采购额</a-button>
+          <a-button type="primary" @click="openBtnModal('SpecialOffer')" :disabled="disabled">特价产品</a-button>
         </div>
         <!-- 列表 -->
         <s-table
@@ -57,7 +57,13 @@
           <!-- 门槛规则 -->
           <template slot="cillProduct" slot-scope="text, record">
             <div v-if="record.gateFlag === '1'">
-              购买满{{ record.gateAmount }}元门槛产品,可使用 {{ record.quotaAmount }}元配额,采购规则中的正价商品
+              <span v-if="record.gateType==='RATIO_AMOUNT'">
+                购买门槛产品金额{{ record.gateAmount*100 }}%作为配额
+              </span>
+              <span v-else-if="record.gateType==='MIN_AMOUNT'">
+                购买门槛产品满最低金额{{ record.gateAmount }}不限制配额。
+              </span>
+              <span v-else>购买满{{ record.gateAmount }}元门槛产品,可使用 {{ record.quotaAmount }}元配额,采购规则中的正价商品</span>
             </div>
             <span v-else>--</span>
           </template>
@@ -98,6 +104,9 @@
               id="promotionList-edit-btn">详情</a-button>
           </template>
         </s-table>
+        <div style="text-align:center;margin-top:20px;">
+          <a-button type="primary" size="large" style="padding:0 30px;" @click="handleSubmit" :disabled="disabled">提交</a-button>
+        </div>
       </a-card>
     </a-spin>
     <!-- 查看参与客户 -->
@@ -107,11 +116,11 @@
     <!-- 详情 -->
     <detailModal :openModal="openDetailModal" :itemSn="detailSn" @close="closeDetailModal"></detailModal>
     <!-- 买产品送产品  弹窗 -->
-    <sendProductsModal :openModal="openSendProductsModal" :promotionSn="$route.query.sn" @ok="$refs.table.refresh()" @close="openSendProductsModal = false"></sendProductsModal>
+    <sendProductsModal :openModal="openSendProductsModal" :itemSn="detailSn" :promotionSn="$route.query.sn" @ok="$refs.table.refresh()" @close="openSendProductsModal = false"></sendProductsModal>
     <!-- 买产品送采购额 弹窗 -->
-    <sendAmountModal :openModal="openSendAmountModal" :promotionSn="$route.query.sn" @ok="$refs.table.refresh()" @close="openSendAmountModal = false"></sendAmountModal>
+    <sendAmountModal :openModal="openSendAmountModal" :itemSn="detailSn" :promotionSn="$route.query.sn" @ok="$refs.table.refresh()" @close="openSendAmountModal = false"></sendAmountModal>
     <!-- 特价产品  弹窗 -->
-    <specialOfferModal :openModal="openSpecialOfferModal" :promotionSn="$route.query.sn" @ok="$refs.table.refresh()" @close="openSpecialOfferModal = false"></specialOfferModal>
+    <specialOfferModal :openModal="openSpecialOfferModal" :itemSn="detailSn" :promotionSn="$route.query.sn" @ok="$refs.table.refresh()" @close="openSpecialOfferModal = false"></specialOfferModal>
   </div>
 </template>
 
@@ -124,7 +133,7 @@ import detailModal from './detailModal'
 import sendProductsModal from './sendProductsModal'
 import sendAmountModal from './sendAmountModal'
 import specialOfferModal from './specialOfferModal'
-import { getRuleQueryList, dealerPromotionInfo, promotionRulesDel } from '@/api/promotion'
+import { getRuleQueryList, dealerPromotionInfo, promotionRulesDel, promotionSubmit } from '@/api/promotion'
 export default {
   name: 'SalesOrderWarehouseDetail',
   mixins: [commonMixin],
@@ -148,7 +157,7 @@ export default {
       loadData: parameter => {
         this.disabled = true
         this.spinning = true
-        const dataAjax = Object.assign(parameter, { sn: this.$route.query.sn })
+        const dataAjax = Object.assign(parameter, { promotionSn: this.$route.query.sn })
         return getRuleQueryList(dataAjax).then(res => {
           let data
           if (res.status == 200) {
@@ -171,8 +180,9 @@ export default {
       const arr = [
         { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
         { title: '促销类型', dataIndex: 'promotionRuleTypeDictValue', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '促销简称', dataIndex: 'description', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '规则门槛', scopedSlots: { customRender: 'cillProduct' }, width: '20%', align: 'center' },
-        { title: '规则', scopedSlots: { customRender: 'ruleProduct' }, width: '28%', align: 'center' },
+        { title: '规则', scopedSlots: { customRender: 'ruleProduct' }, width: '20%', 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' }
@@ -206,17 +216,11 @@ export default {
         }
       })
     },
-    // 买产品送产品
-    handleProduct () {
-      this.openSendProductsModal = true
-    },
-    // 买产品送采购额
-    handleAmount () {
-      this.openSendAmountModal = true
-    },
-    // 特价产品
-    handleSpecialProduct () {
-      this.openSpecialOfferModal = true
+    // 买产品送产品、买产品送采购额、特价产品   弹窗
+    openBtnModal (str) {
+      this.detailSn = null
+      const name = 'open' + str + 'Modal'
+      this[name] = true
     },
     // 查看客户
     handleSee () {
@@ -246,8 +250,27 @@ export default {
         }
       })
     },
-    handleEdit () {
-
+    // 提交
+    handleSubmit () {
+      const _this = this
+      _this.disabled = true
+      promotionSubmit({ sn: _this.$route.query.sn }).then(res => {
+        if (res.status == 200) {
+          _this.$message.success(res.message)
+          _this.handleBack()
+        }
+        _this.disabled = false
+      })
+    },
+    handleEdit (row) {
+      this.detailSn = row.promotionRuleSn
+      if (row.promotionRuleType === 'BUY_PROD_GIVE_PROD') {
+        this.openSendProductsModal = true
+      } else if (row.promotionRuleType === 'BUY_PROD_GIVE_MONEY') {
+        this.openSendAmountModal = true
+      } else {
+        this.openSpecialOfferModal = true
+      }
     }
   },
   mounted () {

+ 2 - 3
src/views/promotionRulesManagement/dealerPromotions/detailModal.vue

@@ -13,12 +13,11 @@
         id="dealerPromotions-basicInfo-form"
         ref="ruleForm"
         :model="form"
-        :rules="rules"
         :label-col="formItemLayout.labelCol"
         :wrapper-col="formItemLayout.wrapperCol" >
-        <a-form-model-item label="规则门槛" prop="gateFlag" v-if="form.gateFlag">
+        <a-form-model-item label="规则门槛" v-if="form.gateFlag">
           <div>{{ form.gateFlag=== '0'?'无':'有' }}</div>
-          <div v-if="gateFlag==='1'">购买满{{ form.gateAmount }}元门槛产品,可使用{{ form.quotaAmount }}元配额,采购规则中的正价商品(配额算销售额)</div>
+          <div v-if="form.gateFlag==='1'">购买满{{ form.gateAmount }}元门槛产品,可使用{{ form.quotaAmount }}元配额,采购规则中的正价商品(配额算销售额)</div>
         </a-form-model-item>
         <!-- 买产品送产品 -->
         <a-form-model-item label="满赠规则" prop="regularSameFlag" v-if="form.promotionRuleType ==='BUY_PROD_GIVE_PROD'">

+ 19 - 46
src/views/promotionRulesManagement/dealerPromotions/editActiveEndTime.vue

@@ -16,13 +16,13 @@
         :rules="rules"
         :label-col="formItemLayout.labelCol"
         :wrapper-col="formItemLayout.wrapperCol" >
-        <a-form-model-item label="" prop="time">
-          <div style="margin-left:40px;">确定要变更促销名称1的促销时间吗?</div>
+        <a-form-model-item label="" prop="name">
+          <div style="margin-left:40px;">确定要变更{{ form.name }}的促销时间吗?</div>
         </a-form-model-item>
         <a-form-model-item label="原结束日期" prop="time">
-          <span>2023-10-01</span>
+          <span>{{ form.timeStart }}</span>
         </a-form-model-item>
-        <a-form-model-item label="变更后结束日期" prop="supplierSn">
+        <a-form-model-item label="变更后结束日期" prop="timeEnd">
           <a-date-picker style="width:90%" @change="onChange" :format="dateFormat"/>
         </a-form-model-item>
       </a-form-model>
@@ -37,7 +37,7 @@
 <script>
 import { commonMixin } from '@/utils/mixin'
 import moment from 'moment'
-import { sparePartsReturnSave, sparePartsReturnInfo } from '@/api/sparePartsReturn'
+import { promotionDateModify } from '@/api/promotion'
 export default {
   name: 'EditActiveEndTimeModal',
   mixins: [commonMixin],
@@ -55,29 +55,28 @@ export default {
         wrapperCol: { span: 16 }
       },
       form: {
-        time: ''
+        name: '',
+        timeStart: '',
+        timeEnd: ''
       },
       dateFormat: 'YYYY-MM-DD',
       rules: {
-        supplierSn: [
-          { required: true, message: '请选择供应商名称', trigger: 'change' }
+        timeEnd: [
+          { required: true, message: '请选择变更的结束时间', trigger: 'change' }
         ]
       }
     }
   },
   methods: {
     onChange (date, dateString) {
-      console.log(date, dateString)
+      this.form.timeEnd = dateString + ' 23:59:59'
     },
     //  保存
     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 => {
+          promotionDateModify({ promotionSn: _this.form.sn, promotionDateStart: _this.form.timeStart, promotionDateEnd: this.form.timeEnd }).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
               setTimeout(() => {
@@ -94,27 +93,9 @@ export default {
         }
       })
     },
-    // 获取编辑详情
-    getDetail () {
-      sparePartsReturnInfo({ sn: this.itemSn }).then(res => {
-        if (res.status == 200) {
-          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
-        }
-      })
+    // 获取显示内容
+    setData (obj) {
+      this.form = { ...this.form, ...obj }
     },
     // 不可选日期
     disabledDate (date, dateStrings) {
@@ -130,18 +111,10 @@ export default {
     isShow (newValue, oldValue) {
       if (!newValue) {
         this.$emit('close')
-        this.attachList = []
-        this.supplierName = null
-        this.$nextTick(() => {
-          this.$refs.attachList.setFileList('')
-          this.$refs.ruleForm.resetFields()
-        })
-      } else {
-        if (this.itemSn) {
-          this.getDetail()
-        } else {
-          // 默认仓库
-          this.form.warehouseSn = this.isShowWarehouse ? undefined : this.defWarehouse && this.defWarehouse.warehouseSn
+        this.form = {
+          name: '',
+          timeStart: '',
+          timeEnd: ''
         }
       }
     }

+ 78 - 87
src/views/promotionRulesManagement/dealerPromotions/list.vue

@@ -88,20 +88,20 @@
         <!-- 发布状态 -->
         <template slot="releaseStatus" slot-scope="text, record">
           <a-switch
-            v-if="record.enabledFlag"
+            v-if="record.state === 'NOT_START'||record.state ==='RUNNING'"
             id="promotionList-enable"
             @change="changeStatus(record)"
             :checked="record.enabledFlag == 1 ? true : false"></a-switch>
         </template>
         <!-- 操作 -->
-        <!-- state 待提交 WAIT_SUBMIT 待审核 WAIT_AUDIT 未开始 NO_START 进行中 A_FOOT 已完结 FINISH 审核不通过 AUDIT_REJECT -->
+        <!--  state 待提交:WAIT_SUBMIT 待审核:WAIT_AUDIT 未开始:NOT_START 进行中:RUNNING 审核不通过:AUDIT_REJECT 已结束:IS_OVER -->
         <template slot="action" slot-scope="text, record">
           <a-button
             size="small"
             type="link"
             class="button-warning"
             @click="handleSetRules(record)"
-            v-if="record.state =='WAIT_SUBMIT'"
+            v-if="record.state =='WAIT_SUBMIT'||record.state == 'AUDIT_REJECT'"
             id="allocateBillList-examine-btn">规则设置</a-button>
           <a-button
             size="small"
@@ -120,14 +120,14 @@
           <a-button
             size="small"
             type="link"
-            v-if="record.state == 'NO_START' || record.state=='A_FOOT'"
+            v-if="record.state == 'NOT_START' || record.state=='RUNNING'"
             @click="handleTime(record)"
             class="button-info"
             id="promotionList-edit-btn">促销时间变更</a-button>
           <a-button
             size="small"
             type="link"
-            v-if="record.state == 'NO_START' || record.state=='A_FOOT'"
+            v-if="record.state == 'NO_START' || record.state=='RUNNING'"
             @click="handleEnd(record)"
             class="button-info"
             id="promotionList-edit-btn">终止</a-button>
@@ -138,7 +138,7 @@
             @click="handleDel(record)"
             class="button-error"
             id="promotionList-del-btn">删除</a-button>
-          <div v-if="record.state == 'FINISH'">--</div>
+          <div v-if="record.state == 'IS_OVER'">--</div>
         </template>
       </s-table>
     </a-spin>
@@ -147,7 +147,36 @@
     <!-- 新增/编辑弹窗-->
     <add-modal v-drag :itemSn="itemSn" :openModal="openModal" @ok="handleOk" @close="openModal=false" />
     <!-- 促销时间变更 -->
-    <edit-active-end-time v-drag :openModal="editEndModal" @ok="handleEditOk" @close="editEndModal=false" />
+    <edit-active-end-time ref="editTime" v-drag :openModal="editEndModal" @ok="$refs.table.refresh()" @close="editEndModal=false" />
+    <!-- 审核弹窗 -->
+    <a-modal
+      :closable="false"
+      v-model="openAuditModal"
+      :footer="null"
+      width="416px"
+      centered>
+      <div style="display:flex;margin:30px 0 20px 20px;">
+        <a-icon type="question-circle" :style="{fontSize:'23px',color:'#faad14'}"/>
+        <div style="margin-left:10px;">
+          <p style="font-size:16px;font-wight:bold;">提示</p>
+          <p>请点击下方按钮确认操作?</p>
+        </div>
+      </div>
+      <!-- 按钮 -->
+      <div style="text-align: right;">
+        <a-button
+          id="auditModal-cancel"
+          class="button-cancel"
+          @click="closeAuditModal"
+          style="margin-right: 15px;">审核不通过</a-button>
+        <a-button
+          type="primary"
+          id="auditModal-save"
+          class="button-primary"
+          @click="handleAuditModal"
+        >审核通过</a-button>
+      </div>
+    </a-modal>
   </a-card>
 </template>
 
@@ -161,10 +190,9 @@ import rangeDate from '@/views/common/rangeDate.vue'
 // import chooseDepartUserModal from './chooseDepartUserModal.vue'
 import editActiveEndTime from './editActiveEndTime.vue'
 import reportModal from '@/views/common/reportModal.vue'
-import { hdExportExcel } from '@/libs/exportExcel'
 import supplier from '@/views/common/supplier.js'
 import warehouse from '@/views/common/chooseWarehouse.js'
-import { dealerPromotionList, dealerPromotionDel, sparePartsReturnExportDetail, againSubmit } from '@/api/promotion'
+import { dealerPromotionList, dealerPromotionDel, modifyEnabledFlag, promotionAudit, promotionIsOver } from '@/api/promotion'
 export default {
   name: 'PromotionManagementList',
   mixins: [commonMixin],
@@ -175,10 +203,8 @@ export default {
       disabled: false, //  查询、重置按钮是否可操作
       openModal: false, // 新增弹框是否显示
       openCustomerModal: false, // 参与客户弹窗
-      editEndModal: false,
+      editEndModal: false, // 更改促销时间
       openDetailModal: false, // 详情弹窗
-      showExport: false,
-      exportLoading: false,
       tableHeight: 0,
       // 查询参数
       queryParam: {
@@ -192,9 +218,10 @@ export default {
         { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
         { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '促销名称', scopedSlots: { customRender: 'promotionName' }, width: '14%', align: 'center' },
+        { title: '促销简称', dataIndex: 'description', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
         { title: '促销时间', scopedSlots: { customRender: 'promotionTime' }, width: '15%', align: 'center' },
         { title: '参与客户', scopedSlots: { customRender: 'joinCustomers' }, width: '12%', align: 'center', ellipsis: true },
-        { title: '促销描述', dataIndex: 'description', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '促销描述', dataIndex: 'content', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
         { title: '活动状态', dataIndex: 'stateDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '发布状态', scopedSlots: { customRender: 'releaseStatus' }, width: '9%', align: 'center', ellipsis: true },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
@@ -217,9 +244,8 @@ export default {
           return data
         })
       },
-      itemSnSh: null,
       itemSn: null, // 经销商促销活动SN
-      auditTime: null// 审核时间
+      openAuditModal: false // 审核弹窗
     }
   },
   methods: {
@@ -232,19 +258,6 @@ export default {
       this.queryParam.beginDate = date[0]
       this.queryParam.endDate = date[1]
     },
-    //  导出
-    handleExport () {
-      const _this = this
-      _this.$store.state.app.curActionPermission = 'B_promotionListExport'
-      _this.exportLoading = true
-      _this.spinning = true
-      hdExportExcel(sparePartsReturnExportDetail, _this.queryParam, '采购退货', function () {
-        _this.exportLoading = false
-        _this.spinning = false
-        _this.showExport = true
-        _this.$store.state.app.curActionPermission = ''
-      })
-    },
     //  新增
     handleAdd () {
       this.itemSn = null
@@ -253,9 +266,9 @@ export default {
     // 参与客户
     handleCustomers (row) {
       this.openCustomerModal = true
-      // this.$nextTick(() => {
-      //   this.$refs.lookUpCustomers.pageInit({ dealerSnList: row.promoBuyerSnSet ? row.promoBuyerSnSet : undefined, promoActiveSn: row.promoActiveSn })
-      // })
+      this.$nextTick(() => {
+        this.$refs.lookUpCustomers.pageInit({ dealerSnList: row.dealerSnList })
+      })
     },
     //  基本信息  保存
     handleOk () {
@@ -270,11 +283,11 @@ export default {
     // 发布状态
     changeStatus (record) {
       const params = {
-        id: record.id,
-        flag: record.loginFlag == 1 ? '0' : '1'
+        promotionSn: record.promotionSn,
+        enabledFlag: record.enabledFlag == 1 ? '0' : '1'
       }
       this.spinning = true
-      dealerUserEnable(params).then(res => {
+      modifyEnabledFlag(params).then(res => {
         if (res.status == 200) {
           this.$message.success(res.message)
           this.$refs.table.refresh()
@@ -292,35 +305,39 @@ export default {
     // 审核
     handleCheck (row) {
       const _this = this
-      this.$confirm({
-        title: '提示',
-        content: '请点击下方按钮确认操作?',
-        cancelText: '审核不通过',
-        okText: '审核通过',
-        centered: true,
-        closable: true,
-        onOk () {
-          _this.spinning = true
-          sparePartsReturnDelete({ sn: row.sparePartsReturnSn }).then(res => {
-            if (res.status == 200) {
-              _this.$message.success(res.message)
-              _this.$refs.table.refresh()
-              _this.spinning = false
-            } else {
-              _this.spinning = false
-            }
-          })
-        },
-        onCancel (e) {
-          console.log('不通过', e)
+      _this.itemSn = row.promotionSn
+      _this.openAuditModal = true
+    },
+    handleAuditModal () {
+      this.handleAudit({ promotionSn: this.itemSn, auditFlag: 1 })
+    },
+    closeAuditModal () {
+      this.handleAudit({ promotionSn: this.itemSn, auditFlag: 0 })
+    },
+    handleAudit (ajaxData) {
+      const _this = this
+      _this.spinning = true
+      promotionAudit(ajaxData).then(res => {
+        if (res.status == 200) {
+          _this.$message.success(res.message)
+          _this.$refs.table.refresh()
         }
+        _this.itemSn = null
+        _this.openAuditModal = false
+        _this.spinning = false
       })
     },
     // 促销时间变更
-    handleTime () {
+    handleTime (row) {
       this.editEndModal = true
+      const showData = {
+        sn: row.promotionSn,
+        name: row.title,
+        timeStart: row.promotionDateStart,
+        timeEnd: row.promotionDateEnd
+      }
+      this.$refs.editTime.setData(showData)
     },
-    handleEditOk () {},
     // 终止
     handleEnd (row) {
       const _this = this
@@ -330,28 +347,7 @@ export default {
         centered: true,
         onOk () {
           _this.spinning = true
-          sparePartsReturnDelete({ sn: row.sparePartsReturnSn }).then(res => {
-            if (res.status == 200) {
-              _this.$message.success(res.message)
-              _this.$refs.table.refresh()
-              _this.spinning = false
-            } else {
-              _this.spinning = false
-            }
-          })
-        }
-      })
-    },
-    // 再次提交
-    handleResubmit (row) {
-      const _this = this
-      this.$confirm({
-        title: '操作提示',
-        content: '系统将自动生成一个新的采购退货单,新单据中的产品申退数量将以最大可用库存为准,最大可用库存为0时,系统将强制删除已选的对应产品。您可以对新单据进行编辑、提交等操作,原单据保持不变,确认操作吗?',
-        centered: true,
-        onOk () {
-          _this.spinning = true
-          againSubmit({ sparePartsReturnSn: row.sparePartsReturnSn }).then(res => {
+          promotionIsOver({ sn: row.promotionSn }).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
               _this.$refs.table.refresh()
@@ -394,10 +390,8 @@ export default {
       this.queryParam = {
         beginDate: undefined,
         endDate: undefined,
-        sparePartsReturnNo: undefined,
-        supplierSn: undefined,
-        returnReason: undefined,
-        warehouseSn: undefined, // 仓库
+        title: '',
+        publishStatus: undefined, // 发布状态
         state: undefined
       }
       this.$refs.rangeDate.resetDate()
@@ -447,13 +441,10 @@ export default {
   }
 }
 </script>
-<style lang="less">
+<style lang="less" scoped>
   .promotionList-wrap{
     .nameBox{
      padding:0 5px;
     }
-    .common{
-      color: rgba(0, 0, 0);
-    }
   }
 </style>

+ 178 - 55
src/views/promotionRulesManagement/dealerPromotions/sendAmountModal.vue

@@ -16,6 +16,15 @@
         :rules="rules"
         :label-col="formItemLayout.labelCol"
         :wrapper-col="formItemLayout.wrapperCol" >
+        <a-form-model-item label="规则简称" prop="description">
+          <a-input
+            size="small"
+            id="promotionList-description"
+            v-model.trim="form.description"
+            allowClear
+            placeholder="请输入促销简称(最多10个字符)"
+            :maxLength="10"></a-input>
+        </a-form-model-item>
         <a-form-model-item label="规则门槛" prop="gateFlag">
           <a-radio-group v-model="form.gateFlag" button-style="solid" size="small" @change="changeGateFlag">
             <a-radio-button value="1">
@@ -25,12 +34,31 @@
             </a-radio-button>
           </a-radio-group>
-          <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.quotaAmount" :min="0" :precision="2" size="small"/>
-            元配额,采购规则中的正价商品(配额算销售额)
+          <div v-if="form.gateFlag && form.gateFlag === '1'">
+            <v-select
+              size="small"
+              style="width:60%;"
+              v-model="form.gateType"
+              id="promotionList-gateType"
+              code="PROMOTION_GATE_TYPE"
+              placeholder="请选择"
+              allowClear></v-select>
+            <div v-if="form.gateType==='RATIO_AMOUNT'">
+              购买门槛产品金额 <a-input-number v-model="form.gateAmount" :min="0" :max="100" size="small"/> %作为配额
+              <a-tooltip title="如:填写100%,则购买10000元门槛产品,可享受10000配额购买正价产品,根据门槛金额动态调整配额">
+                <a-icon type="question-circle" theme="filled" :style="{ fontSize: '14px', color: 'gray' }"/>
+              </a-tooltip>
+            </div>
+            <div v-if="form.gateType==='MIN_AMOUNT'">
+              购买门槛产品满最低金额 <a-input-number v-model="form.gateAmount" :min="0" :precision="2" size="small"/> 不限制配额。
+            </div>
+            <div class="ruleDescList" v-if="form.gateType==='FIXED_AMOUNT'">
+              购买满
+              <a-input-number v-model="form.gateAmount" :min="0" :precision="2" size="small"/>
+              元门槛产品,可使用
+              <a-input-number v-model="form.quotaAmount" :max="form.gateAmount" :min="0" :precision="2" size="small"/>
+              元配额,采购规则中的正价商品(配额算销售额)
+            </div>
           </div>
         </a-form-model-item>
         <a-form-model-item label="满赠规则" prop="regularSameFlag">
@@ -44,10 +72,23 @@
               </a-select-option>
             </a-select>
             产品购买满
-            <a-input-number v-model="form.regularAmount" :min="0" :step="1" :precision="0" size="small"/>
+            <a-input-number
+              v-model="form.regularAmount"
+              @blur="calculatePrice"
+              :min="0"
+              :step="1"
+              :precision="0"
+              size="small"/>
             元正价产品,送
-            <a-input-number v-model="form.giveAmount" :min="0" :step="1" :precision="0" size="small"/>
-            元%促销品采购额
+            <a-input-number
+              v-model="form.giveAmount"
+              @blur="calculatePrice"
+              :min="0"
+              :step="1"
+              :max="form.regularAmount"
+              :precision="0"
+              size="small"/>
+            元{{ scaleNum }}%促销品采购额
           </div>
         </a-form-model-item>
         <a-form-model-item label="金额叠加" prop="accrualFlag">
@@ -158,7 +199,7 @@ import { commonMixin } from '@/utils/mixin'
 import { VSelect } from '@/components'
 import tableType1 from './tableType1.vue'
 import tableType2 from './tableType2.vue'
-import { promotionSave, sparePartsReturnInfo } from '@/api/promotion'
+import { promotionSave, getRuleDetail } from '@/api/promotion'
 export default {
   name: 'PromotionListBasicInfoModal',
   mixins: [commonMixin],
@@ -171,6 +212,10 @@ export default {
     promotionSn: {
       type: [Number, String],
       default: ''
+    },
+    itemSn: {
+      type: [Number, String],
+      default: ''
     }
   },
   data () {
@@ -183,21 +228,24 @@ export default {
       },
       form: {
         promotionRuleType: 'BUY_PROD_GIVE_MONEY', // 买产品送采购额
+        description: '',
         gateFlag: '0', // 门槛
-        gateAmount: '',
-        quotaAmount: '',
+        gateType: undefined,
+        gateAmount: undefined,
+        quotaAmount: undefined,
         regularSameFlag: '0', // 满赠规则  不同款商品
-        regularAmount: '',
-        giveAmount: '',
+        regularAmount: undefined,
+        giveAmount: undefined,
         restrictCategory: '',
         accrualFlag: '1', // 数量叠加
         minOrderFlag: '1', // 起订金额
-        minOrderAmount: '',
+        minOrderAmount: undefined,
         upperLimitFlag: '1', // 活动经费上限
-        upperLimitAmount: '',
+        upperLimitAmount: undefined,
         scopeFlag: undefined
       },
       rules: {
+        description: [ { required: true, message: '请输入规则简称', trigger: 'blur' } ],
         gateFlag: [ { required: true, message: '请选择规则门槛', trigger: 'change' } ],
         regularSameFlag: [{ required: true, message: '请选择满赠规则', trigger: 'change' }],
         accrualFlag: [{ required: true, message: '请选择数量是否叠加', trigger: 'change' }],
@@ -205,10 +253,18 @@ export default {
         upperLimitFlag: [{ required: true, message: '请选择活动经费上限', trigger: 'change' }],
         scopeFlag: [{ required: true, message: '请选择采购额适用范围', trigger: 'change' }]
       },
-      chooseVal: 'a'
+      chooseVal: 'a',
+      scaleNum: 0
     }
   },
   methods: {
+    // 计算百分比
+    calculatePrice () {
+      const _this = this
+      if (_this.form.regularAmount && _this.form.giveAmount) {
+        _this.scaleNum = Math.floor(((_this.form.giveAmount / _this.form.regularAmount) * 100).toFixed(2))
+      }
+    },
     // 门槛切换  tab 按钮默认显示问题
     changeGateFlag (e) {
       if (this.chooseVal != 'c') {
@@ -222,33 +278,46 @@ export default {
     //  保存
     handleSave () {
       const _this = this
-      // 验证必填
-      if (_this.form.gateFlag == '1') {
-        if (!_this.form.gateAmount || !_this.form.quotaAmount) {
-          _this.$message.warning('规则门槛条件不能为空!')
-          return
-        }
-      }
-      if (!_this.form.regularAmount || !_this.form.giveAmount) {
-        _this.$message.warning('满赠规则条件不能为空!')
-        return
-      }
 
-      if (_this.form.minOrderFlag == 1 && !_this.form.minOrderAmount) {
-        _this.$message.warning('请输入订单起订限制金额数!')
-        return
-      }
-      if (_this.form.upperLimitFlag == 1 && !_this.form.upperLimitAmount) {
-        _this.$message.warning('请输入活动经费上限金额!')
-        return
-      }
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
+          // 验证必填
+          if (_this.form.gateFlag == '1') {
+            if (!_this.form.gateType) {
+              _this.$message.warning('请选择规则门槛设置类型!')
+              return
+            }
+            if (!_this.form.gateAmount) {
+              _this.$message.warning('规则门槛条件不能为空!')
+              return
+            }
+            if (_this.form.gateType === 'FIXED_AMOUNT' && !_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
+          }
+
           const form = JSON.parse(JSON.stringify(_this.form))
           if (form.gateFlag == '1') {
             form.gateProductList = this.$refs.cillProduct.getResultVal()
           } else {
             form.gateProductList = []
+            form.gateAmount = ''
+            form.quotaAmount = ''
+            form.gateType = undefined
           }
           if (form.scopeFlag == '0') {
             form.giftProductList = this.$refs.offerProduct.getResultVal()
@@ -279,18 +348,20 @@ export default {
     resetSearchForm () {
       this.form = {
         promotionRuleType: 'BUY_PROD_GIVE_MONEY', // 买产品送采购额
+        description: '',
         gateFlag: '0', // 门槛
-        gateAmount: '',
-        quotaAmount: '',
+        gateType: undefined,
+        gateAmount: undefined,
+        quotaAmount: undefined,
         regularSameFlag: '0', // 满赠规则  不同款商品
-        regularAmount: '',
-        giveAmount: '',
+        regularAmount: undefined,
+        giveAmount: undefined,
         restrictCategory: '',
         accrualFlag: '1', // 数量叠加
         minOrderFlag: '1', // 起订金额
-        minOrderAmount: '',
+        minOrderAmount: undefined,
         upperLimitFlag: '1', // 活动经费上限
-        upperLimitAmount: '',
+        upperLimitAmount: undefined,
         scopeFlag: undefined,
         gateProductList: undefined,
         giftProductList: undefined,
@@ -305,25 +376,77 @@ export default {
     },
     // 获取编辑详情
     getDetail () {
-      sparePartsReturnInfo({ sn: this.itemSn }).then(res => {
+      const _this = this
+      getRuleDetail({ sn: this.itemSn }).then(res => {
         if (res.status == 200) {
+          this.chooseVal = res.data.gateFlag == '0' ? 'b' : 'a'
           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
+          // 重新组成保存数据
+          if (resultObj.gateProductList && resultObj.gateProductList.length > 0) {
+            resultObj.gateProductList = _this.newData(resultObj.gateProductList)
+            this.$refs.cillProduct.setTabVal(resultObj.gateProductList)
           }
-          this.$nextTick(() => {
-            this.$refs.attachList.setFileList(this.attachList)
+          if (resultObj.regularProductList && resultObj.regularProductList.length > 0) {
+            resultObj.regularProductList = _this.newData(resultObj.regularProductList)
+            this.$refs.normalPriceProduct.setTabVal(resultObj.regularProductList)
+          }
+          if (resultObj.giftProductList && resultObj.giftProductList.length > 0) {
+            resultObj.giftProductList = _this.newData(resultObj.giftProductList)
+            this.$refs.offerProduct.setTabVal(resultObj.giftProductList)
+          }
+          this.form = { ...this.form, ...resultObj }
+        }
+      })
+    },
+    newData (list) {
+      list.forEach(con => {
+        // 品牌
+        if (con.productBrandList) {
+          const brandList = []
+          con.productBrandList.forEach(item => {
+            item.brandName = item.productBrandName
+            const brandObj = {
+              productBrandSn: item.productBrandSn
+            }
+            brandList.push(brandObj)
           })
-          this.form = { ...this.form, ...obj }
-        } else {
-          this.detailsData = null
+          con.productBrandArr = con.productBrandList
+          con.productBrandList = brandList
+        }
+        // 分类
+        if (con.productTypeList) {
+          const typeList = []
+          con.productTypeList.forEach(item => {
+            const typeObj = {}
+            item.title = ''
+            const num = 3
+            for (var i = 0; i < num; i++) {
+              if (item['productTypeName' + (i + 1)]) {
+                item.title += item['productTypeName' + (i + 1)] + (item['productTypeName' + (i + 1)] ? '/' : '')
+                typeObj['productTypeSn' + (i + 1)] = item['productTypeSn' + (i + 1)] ? item['productTypeSn' + (i + 1)] : ''
+              }
+            }
+            item.title = item.title.slice(0, item.title.length - 1)
+            item.id = item.productTypeSn3 ? item.productTypeSn3 : item.productTypeSn2 ? item.productTypeSn2 : item.productTypeSn1
+            typeList.push(typeObj)
+          })
+          con.productTypeArr = con.productTypeList
+          con.productTypeList = typeList
+        }
+        // 产品
+        if (con.productThisList) {
+          const productList = []
+          con.productThisList.forEach(item => {
+            const productObj = {
+              productCode: item.productCode,
+              productSn: item.productSn
+            }
+            productList.push(productObj)
+          })
+          con.productThisList = productList
         }
       })
+      return list
     }
   },
   watch: {

+ 183 - 63
src/views/promotionRulesManagement/dealerPromotions/sendProductsModal.vue

@@ -16,6 +16,15 @@
         :rules="rules"
         :label-col="formItemLayout.labelCol"
         :wrapper-col="formItemLayout.wrapperCol" >
+        <a-form-model-item label="规则简称" prop="description">
+          <a-input
+            size="small"
+            id="promotionList-description"
+            v-model.trim="form.description"
+            allowClear
+            placeholder="请输入促销简称(最多10个字符)"
+            :maxLength="10"></a-input>
+        </a-form-model-item>
         <a-form-model-item label="规则门槛" prop="gateFlag">
           <a-radio-group v-model="form.gateFlag" button-style="solid" size="small" @change="changeGateFlag">
             <a-radio-button value="1">
@@ -25,12 +34,31 @@
             </a-radio-button>
           </a-radio-group>
-          <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.quotaAmount" :min="0" :precision="2" size="small"/>
-            元配额,采购规则中的正价商品(配额算销售额)
+          <div v-if="form.gateFlag && form.gateFlag === '1'">
+            <v-select
+              size="small"
+              style="width:60%;"
+              v-model="form.gateType"
+              id="promotionList-gateType"
+              code="PROMOTION_GATE_TYPE"
+              placeholder="请选择"
+              allowClear></v-select>
+            <div v-if="form.gateType==='RATIO_AMOUNT'">
+              购买门槛产品金额 <a-input-number v-model="form.gateAmount" :min="0" :max="100" size="small"/> %作为配额
+              <a-tooltip title="如:填写100%,则购买10000元门槛产品,可享受10000配额购买正价产品,根据门槛金额动态调整配额">
+                <a-icon type="question-circle" theme="filled" :style="{ fontSize: '14px', color: 'gray' }"/>
+              </a-tooltip>
+            </div>
+            <div v-if="form.gateType==='MIN_AMOUNT'">
+              购买门槛产品满最低金额 <a-input-number v-model="form.gateAmount" :min="0" :precision="2" size="small"/> 不限制配额。
+            </div>
+            <div class="ruleDescList" v-if="form.gateType==='FIXED_AMOUNT'">
+              购买满
+              <a-input-number v-model="form.gateAmount" :min="0" :precision="2" size="small"/>
+              元门槛产品,可使用
+              <a-input-number v-model="form.quotaAmount" :max="form.gateAmount" :min="0" :precision="2" size="small"/>
+              元配额,采购规则中的正价商品(配额算销售额)
+            </div>
           </div>
         </a-form-model-item>
         <a-form-model-item label="满赠规则" prop="regularSameFlag">
@@ -46,14 +74,26 @@
             产品购买满
             <a-input-number v-model="form.regularQty" :min="0" :step="1" :precision="0" size="small"/>
             个正价产品,送
-            <a-input-number v-model="form.promotionQty" :min="0" :step="1" :precision="0" size="small"/>
+            <a-input-number
+              v-model="form.promotionQty"
+              :max="form.regularQty"
+              :min="0"
+              :step="1"
+              :precision="0"
+              size="small"/>
             个促销产品
           </div>
           <div class="ruleDescList">
-            <a-checkbox size="small" :value="form.restrictFlag">
+            <a-checkbox size="small" @change="onChange">
               限制正价产品款数
             </a-checkbox>
-            <a-input-number v-model="form.restrictCategory" :min="0" :step="1" :precision="0" size="small"/>
+            <a-input-number
+              v-if="form.restrictFlag==='1'"
+              v-model="form.restrictCategory"
+              :min="0"
+              :step="1"
+              :precision="0"
+              size="small"/>
           </div>
         </a-form-model-item>
         <a-form-model-item label="数量叠加" prop="accrualFlag">
@@ -69,9 +109,9 @@
         </a-form-model-item>
         <a-form-model-item prop="minOrderFlag">
           <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-tooltip>
+            </a-tooltip> -->
             订单起订金额
           </span>
           <a-select v-model="form.minOrderFlag" style="width: 160px" size="small">
@@ -94,9 +134,9 @@
         </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-tooltip title="What do you want others to call you?">
               <a-icon type="info-circle" />
-            </a-tooltip>
+            </a-tooltip> -->
             活动经费上限
           </span>
           <a-select v-model="form.upperLimitFlag" style="width: 160px" size="small">
@@ -164,7 +204,7 @@ import { commonMixin } from '@/utils/mixin'
 import { VSelect } from '@/components'
 import tableType1 from './tableType1.vue'
 import tableType2 from './tableType2.vue'
-import { promotionSave, sparePartsReturnInfo } from '@/api/promotion'
+import { promotionSave, getRuleDetail } from '@/api/promotion'
 export default {
   name: 'PromotionListBasicInfoModal',
   mixins: [commonMixin],
@@ -177,6 +217,10 @@ export default {
     promotionSn: {
       type: [Number, String],
       default: ''
+    },
+    itemSn: {
+      type: [Number, String],
+      default: ''
     }
   },
   data () {
@@ -189,22 +233,25 @@ export default {
       },
       form: {
         promotionRuleType: 'BUY_PROD_GIVE_PROD', // 买产品送产品
+        description: '', // 简称
         gateFlag: '0', // 门槛
-        gateAmount: '',
-        quotaAmount: '',
+        gateType: undefined,
+        gateAmount: undefined,
+        quotaAmount: undefined,
         regularSameFlag: '0', // 满赠规则  不同款商品
-        regularQty: '',
-        promotionQty: '',
+        regularQty: undefined,
+        promotionQty: undefined,
         restrictFlag: undefined, // 限制正价产品款数
         restrictCategory: '',
         accrualFlag: '1', // 数量叠加
         minOrderFlag: '1', // 起订金额
-        minOrderAmount: '',
+        minOrderAmount: undefined,
         upperLimitFlag: '1', // 活动经费上限
-        upperLimitAmount: '',
+        upperLimitAmount: undefined,
         regularPromotionSameFlag: undefined
       },
       rules: {
+        description: [ { required: true, message: '请输入规则简称', trigger: 'blur' } ],
         gateFlag: [ { required: true, message: '请选择规则门槛', trigger: 'change' } ],
         regularSameFlag: [{ required: true, message: '请选择满赠规则', trigger: 'change' }],
         accrualFlag: [{ required: true, message: '请选择数量是否叠加', trigger: 'change' }],
@@ -216,6 +263,9 @@ export default {
     }
   },
   methods: {
+    onChange (e) {
+      this.form.restrictFlag = e.target.checked ? '1' : '0'
+    },
     // 门槛切换  tab 按钮默认显示问题
     changeGateFlag (e) {
       if (this.chooseVal != 'c') {
@@ -229,37 +279,50 @@ export default {
     //  保存
     handleSave () {
       const _this = this
-      // 验证必填
-      if (_this.form.gateFlag == '1') {
-        if (!_this.form.gateAmount || !_this.form.quotaAmount) {
-          _this.$message.warning('规则门槛条件不能为空!')
-          return
-        }
-      }
-      if (!_this.form.regularQty || !_this.form.promotionQty) {
-        _this.$message.warning('满赠规则条件不能为空!')
-        return
-      }
-      if (_this.form.restrictFlag && !_this.form.restrictCategory) {
-        _this.$message.warning('请输入限制正价产品款数个数!')
-        return
-      }
-
-      if (_this.form.minOrderFlag == 1 && !_this.form.minOrderAmount) {
-        _this.$message.warning('请输入订单起订限制金额数!')
-        return
-      }
-      if (_this.form.upperLimitFlag == 1 && !_this.form.upperLimitAmount) {
-        _this.$message.warning('请输入活动经费上限金额!')
-        return
-      }
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
+          // 验证必填
+          if (_this.form.gateFlag == '1') {
+            if (!_this.form.gateType) {
+              _this.$message.warning('请选择规则门槛设置类型!')
+              return
+            }
+            if (!_this.form.gateAmount) {
+              _this.$message.warning('规则门槛条件不能为空!')
+              return
+            }
+            if (_this.form.gateType === 'FIXED_AMOUNT' && !_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
+          }
+
           const form = JSON.parse(JSON.stringify(_this.form))
           if (form.gateFlag == '1') {
             form.gateProductList = this.$refs.cillProduct.getResultVal()
+            form.gateAmount = form.gateType === 'RATIO_AMOUNT' ? form.gateAmount / 100 : form.gateAmount
           } else {
             form.gateProductList = []
+            form.gateAmount = ''
+            form.quotaAmount = ''
+            form.gateType = undefined
           }
           if (form.regularPromotionSameFlag == '0') {
             form.giftProductList = this.$refs.offerProduct.getResultVal()
@@ -290,19 +353,21 @@ export default {
     resetSearchForm () {
       this.form = {
         promotionRuleType: 'BUY_PROD_GIVE_PROD', // 买产品送产品
+        description: '', // 简称
         gateFlag: '0', // 门槛
-        gateAmount: '',
-        quotaAmount: '',
+        gateType: undefined,
+        gateAmount: undefined,
+        quotaAmount: undefined,
         regularSameFlag: '0', // 满赠规则  不同款商品
-        regularQty: '',
-        promotionQty: '',
+        regularQty: undefined,
+        promotionQty: undefined,
         restrictFlag: undefined, // 限制正价产品款数
         restrictCategory: '',
         accrualFlag: '1', // 数量叠加
         minOrderFlag: '1', // 起订金额
-        minOrderAmount: '',
+        minOrderAmount: undefined,
         upperLimitFlag: '1', // 活动经费上限
-        upperLimitAmount: '',
+        upperLimitAmount: undefined,
         regularPromotionSameFlag: undefined,
         gateProductList: undefined,
         giftProductList: undefined,
@@ -317,25 +382,80 @@ export default {
     },
     // 获取编辑详情
     getDetail () {
-      sparePartsReturnInfo({ sn: this.itemSn }).then(res => {
+      const _this = this
+      getRuleDetail({ sn: this.itemSn }).then(res => {
         if (res.status == 200) {
           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.chooseVal = resultObj.gateFlag == '0' ? 'b' : 'a'
+          if (resultObj.gateFlag === '1') {
+            resultObj.gateAmount = resultObj.gateType === 'RATIO_AMOUNT' ? resultObj.gateAmount * 100 : resultObj.gateAmount
           }
-          this.$nextTick(() => {
-            this.$refs.attachList.setFileList(this.attachList)
+          // 重新组成保存数据
+          if (resultObj.gateProductList && resultObj.gateProductList.length > 0) {
+            resultObj.gateProductList = _this.newData(resultObj.gateProductList)
+            this.$refs.cillProduct.setTabVal(resultObj.gateProductList)
+          }
+          if (resultObj.regularProductList && resultObj.regularProductList.length > 0) {
+            resultObj.regularProductList = _this.newData(resultObj.regularProductList)
+            this.$refs.normalPriceProduct.setTabVal(resultObj.regularProductList)
+          }
+          if (resultObj.giftProductList && resultObj.giftProductList.length > 0) {
+            resultObj.giftProductList = _this.newData(resultObj.giftProductList)
+            this.$refs.offerProduct.setTabVal(resultObj.giftProductList)
+          }
+          this.form = { ...this.form, ...resultObj }
+        }
+      })
+    },
+    newData (list) {
+      list.forEach(con => {
+        // 品牌
+        if (con.productBrandList) {
+          const brandList = []
+          con.productBrandList.forEach(item => {
+            item.brandName = item.productBrandName
+            const brandObj = {
+              productBrandSn: item.productBrandSn
+            }
+            brandList.push(brandObj)
           })
-          this.form = { ...this.form, ...obj }
-        } else {
-          this.detailsData = null
+          con.productBrandArr = con.productBrandList
+          con.productBrandList = brandList
+        }
+        // 分类
+        if (con.productTypeList) {
+          const typeList = []
+          con.productTypeList.forEach(item => {
+            const typeObj = {}
+            item.title = ''
+            const num = 3
+            for (var i = 0; i < num; i++) {
+              if (item['productTypeName' + (i + 1)]) {
+                item.title += item['productTypeName' + (i + 1)] + (item['productTypeName' + (i + 1)] ? '/' : '')
+                typeObj['productTypeSn' + (i + 1)] = item['productTypeSn' + (i + 1)] ? item['productTypeSn' + (i + 1)] : ''
+              }
+            }
+            item.title = item.title.slice(0, item.title.length - 1)
+            item.id = item.productTypeSn3 ? item.productTypeSn3 : item.productTypeSn2 ? item.productTypeSn2 : item.productTypeSn1
+            typeList.push(typeObj)
+          })
+          con.productTypeArr = con.productTypeList
+          con.productTypeList = typeList
+        }
+        // 产品
+        if (con.productThisList) {
+          const productList = []
+          con.productThisList.forEach(item => {
+            const productObj = {
+              productCode: item.productCode,
+              productSn: item.productSn
+            }
+            productList.push(productObj)
+          })
+          con.productThisList = productList
         }
       })
+      return list
     }
   },
   watch: {

+ 130 - 45
src/views/promotionRulesManagement/dealerPromotions/specialOfferModal.vue

@@ -16,6 +16,15 @@
         :rules="rules"
         :label-col="formItemLayout.labelCol"
         :wrapper-col="formItemLayout.wrapperCol" >
+        <a-form-model-item label="规则简称" prop="description">
+          <a-input
+            size="small"
+            id="promotionList-description"
+            v-model.trim="form.description"
+            allowClear
+            placeholder="请输入促销简称(最多10个字符)"
+            :maxLength="10"></a-input>
+        </a-form-model-item>
         <a-form-model-item label="规则门槛" prop="gateFlag">
           <a-radio-group v-model="form.gateFlag" button-style="solid" size="small" @change="handleChange">
             <a-radio-button value="1">
@@ -25,12 +34,31 @@
             </a-radio-button>
           </a-radio-group>
-          <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.quotaAmount" :min="0" :precision="2" size="small"/>
-            元配额,采购规则中的特价商品(配额算销售额)
+          <div v-if="form.gateFlag && form.gateFlag === '1'">
+            <v-select
+              size="small"
+              style="width:60%;"
+              v-model="form.gateType"
+              id="promotionList-gateType"
+              code="PROMOTION_GATE_TYPE"
+              placeholder="请选择"
+              allowClear></v-select>
+            <div v-if="form.gateType==='RATIO_AMOUNT'">
+              购买门槛产品金额 <a-input-number v-model="form.gateAmount" :min="0" :max="100" size="small"/> %作为配额
+              <a-tooltip title="如:填写100%,则购买10000元门槛产品,可享受10000配额购买正价产品,根据门槛金额动态调整配额">
+                <a-icon type="question-circle" theme="filled" :style="{ fontSize: '14px', color: 'gray' }"/>
+              </a-tooltip>
+            </div>
+            <div v-if="form.gateType==='MIN_AMOUNT'">
+              购买门槛产品满最低金额 <a-input-number v-model="form.gateAmount" :min="0" :precision="2" size="small"/> 不限制配额。
+            </div>
+            <div class="ruleDescList" v-if="form.gateType==='FIXED_AMOUNT'">
+              购买满
+              <a-input-number v-model="form.gateAmount" :min="0" :precision="2" size="small"/>
+              元门槛产品,可使用
+              <a-input-number v-model="form.quotaAmount" :max="form.gateAmount" :min="0" :precision="2" size="small"/>
+              元配额,采购规则中的正价商品(配额算销售额)
+            </div>
           </div>
         </a-form-model-item>
         <a-form-model-item prop="minOrderFlag">
@@ -133,7 +161,7 @@ import { commonMixin } from '@/utils/mixin'
 import { VSelect } from '@/components'
 import tableType1 from './tableType1.vue'
 import tableType3 from './tableType3.vue'
-import { promotionSave, sparePartsReturnInfo, getNewScopeSn } from '@/api/promotion'
+import { promotionSave, getRuleDetail, getNewScopeSn } from '@/api/promotion'
 import chooseProductsModal from './chooseProductsModal.vue'
 export default {
   name: 'PromotionListBasicInfoModal',
@@ -147,6 +175,10 @@ export default {
     promotionSn: {
       type: [Number, String],
       default: ''
+    },
+    itemSn: {
+      type: [Number, String],
+      default: ''
     }
   },
   data () {
@@ -159,15 +191,18 @@ export default {
       },
       form: {
         promotionRuleType: 'PROMO_PROD', // 特价产品
+        description: '',
         gateFlag: '0', // 门槛
-        gateAmount: '',
-        quotaAmount: '',
+        gateType: undefined,
+        gateAmount: undefined,
+        quotaAmount: undefined,
         minOrderFlag: '1', // 起订金额
-        minOrderAmount: '',
+        minOrderAmount: undefined,
         upperLimitFlag: '1', // 活动经费上限
-        upperLimitAmount: ''
+        upperLimitAmount: undefined
       },
       rules: {
+        description: [ { required: true, message: '请输入规则简称', trigger: 'blur' } ],
         gateFlag: [ { required: true, message: '请选择规则门槛', trigger: 'change' } ],
         minOrderFlag: [{ required: true, message: '请选择订单起订金额', trigger: 'change' }],
         upperLimitFlag: [{ required: true, message: '请选择活动经费上限', trigger: 'change' }]
@@ -189,23 +224,24 @@ export default {
     //  保存
     handleSave () {
       const _this = this
-      // 验证必填
-      if (_this.form.gateFlag == '1') {
-        if (!_this.form.gateAmount || !_this.form.quotaAmount) {
-          _this.$message.warning('规则门槛条件不能为空!')
-          return
-        }
-      }
-      if (_this.form.minOrderFlag == 1 && !_this.form.minOrderAmount) {
-        _this.$message.warning('请输入订单起订限制金额数!')
-        return
-      }
-      if (_this.form.upperLimitFlag == 1 && !_this.form.upperLimitAmount) {
-        _this.$message.warning('请输入活动经费上限金额!')
-        return
-      }
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
+          // 验证必填
+          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
+          }
+
           const form = JSON.parse(JSON.stringify(_this.form))
           if (form.gateFlag == '1') {
             form.gateProductList = _this.$refs.cillProduct.getResultVal()
@@ -236,13 +272,15 @@ export default {
     resetSearchForm () {
       this.form = {
         promotionRuleType: 'PROMO_PROD', // 特价产品
+        description: '',
         gateFlag: '0', // 门槛
-        gateAmount: '',
-        quotaAmount: '',
+        gateType: undefined,
+        gateAmount: undefined,
+        quotaAmount: undefined,
         minOrderFlag: '1', // 起订金额
-        minOrderAmount: '',
+        minOrderAmount: undefined,
         upperLimitFlag: '1', // 活动经费上限
-        upperLimitAmount: '',
+        upperLimitAmount: undefined,
         gateProductList: undefined,
         specialProductList: undefined
       }
@@ -254,29 +292,76 @@ export default {
     },
     // 获取编辑详情
     getDetail () {
-      sparePartsReturnInfo({ sn: this.itemSn }).then(res => {
+      const _this = this
+      getRuleDetail({ sn: this.itemSn }).then(res => {
         if (res.status == 200) {
+          this.chooseVal = res.data.gateFlag == '0' ? 'd' : 'a'
           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
+          // 重新组成保存数据
+          if (resultObj.gateProductList && resultObj.gateProductList.length > 0) {
+            resultObj.gateProductList = _this.newData(resultObj.gateProductList)
+            this.$refs.cillProduct.setTabVal(resultObj.gateProductList)
           }
-          this.$nextTick(() => {
-            this.$refs.attachList.setFileList(this.attachList)
+          if (resultObj.specialProductList && resultObj.specialProductList.length > 0) {
+            resultObj.specialProductList = _this.newData(resultObj.specialProductList)
+            this.$refs.specialProduct.setSourceData(resultObj.specialProductList)
+          }
+          this.form = { ...this.form, ...resultObj }
+        }
+      })
+    },
+    newData (list) {
+      list.forEach(con => {
+        // 品牌
+        if (con.productBrandList) {
+          const brandList = []
+          con.productBrandList.forEach(item => {
+            item.brandName = item.productBrandName
+            const brandObj = {
+              productBrandSn: item.productBrandSn
+            }
+            brandList.push(brandObj)
           })
-          this.form = { ...this.form, ...obj }
-        } else {
-          this.detailsData = null
+          con.productBrandArr = con.productBrandList
+          con.productBrandList = brandList
+        }
+        // 分类
+        if (con.productTypeList) {
+          const typeList = []
+          con.productTypeList.forEach(item => {
+            const typeObj = {}
+            item.title = ''
+            const num = 3
+            for (var i = 0; i < num; i++) {
+              if (item['productTypeName' + (i + 1)]) {
+                item.title += item['productTypeName' + (i + 1)] + (item['productTypeName' + (i + 1)] ? '/' : '')
+                typeObj['productTypeSn' + (i + 1)] = item['productTypeSn' + (i + 1)] ? item['productTypeSn' + (i + 1)] : ''
+              }
+            }
+            item.title = item.title.slice(0, item.title.length - 1)
+            item.id = item.productTypeSn3 ? item.productTypeSn3 : item.productTypeSn2 ? item.productTypeSn2 : item.productTypeSn1
+            typeList.push(typeObj)
+          })
+          con.productTypeArr = con.productTypeList
+          con.productTypeList = typeList
+        }
+        // 产品
+        if (con.productThisList) {
+          const productList = []
+          con.productThisList.forEach(item => {
+            const productObj = {
+              productCode: item.productCode,
+              productSn: item.productSn
+            }
+            productList.push(productObj)
+          })
+          con.productThisList = productList
         }
       })
+      return list
     },
     // +新增产品
     handleProductsOk (con) {
-      debugger
       const chooseProductsList = []
       const _this = this
       con.forEach(item => {
@@ -284,7 +369,7 @@ export default {
           if (res.status == 200) {
             const newData = {
               productScopeSn: res.data,
-              dataSourceOrigin: 'sel',
+              dataSourceOrigin: '1',
               productTypeArr: [],
               productTypeList: [],
               productBrandArr: [{ brandSn: item.productBrandSn, brandName: item.productBrandName }],

+ 49 - 12
src/views/promotionRulesManagement/dealerPromotions/tableType1.vue

@@ -47,7 +47,7 @@
         <div style="max-height:106spx;overflow-y:scroll;">
           <a-row v-if="record.productBrandArr && record.productBrandArr.length>0">
             <a-col :span="20">
-              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.productScopeSn,item,'brandList')" v-for="item in record.productBrandArr" :key="item.productBrandSn">
+              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.productScopeSn,item,'brandList')" v-for="item in record.productBrandArr" :key="item.brandSn">
                 {{ item.brandName }}
               </a-tag>
             </a-col>
@@ -107,7 +107,7 @@
             v-model="record.unitQty"
             :min="0"
             :step="1"
-            :precision="2"
+            :precision="0"
             placeholder="请输入"/>
         </div>
       </template>
@@ -126,7 +126,7 @@
       <a-button id="tableType1-add" type="primary" class="button-gray" @click="handleAddRow">+新增一行</a-button>
     </div>
     <!-- 选择产品品牌 -->
-    <chooseBrandModal :openModal="openBrandModal" :chooseData="chooseBrand" @close="openBrandModal=false" @ok="handleBrandOk" />
+    <chooseBrandModal ref="brandBox" :openModal="openBrandModal" :chooseData="chooseBrand" @close="openBrandModal=false" @ok="handleBrandOk" />
     <!-- 选择产品分类 -->
     <chooseTypeModal :openModal="openTypeModal" :linkageStatus="false" :chooseData="chooseType" @close="openTypeModal=false" @ok="handleTypeOk" />
     <!-- 选择产品 -->
@@ -150,12 +150,6 @@ export default {
   name: 'TableType1',
   mixins: [commonMixin],
   components: { VSelect, ChooseBrandModal, ChooseTypeModal, chooseProductsModal },
-  props: {
-    itemSn: {
-      type: [Number, String],
-      default: ''
-    }
-  },
   data () {
     return {
       spinning: false,
@@ -258,8 +252,24 @@ export default {
     },
     // 添加产品品牌
     addBrandTag (pos, row) {
-      this.brandTagIndex = pos
-      this.openBrandModal = true
+      const _this = this
+      _this.brandTagIndex = pos
+      // 每行品牌都是唯一滴
+      // const snArr = []
+      // const snObjList = []
+      // _this.dataSource.forEach(item => {
+      //   if (item.productBrandList && item.productBrandList.length > 0) {
+      //     item.productBrandList.forEach(con => {
+      //       con.goodsSn = con.productBrandSn
+      //       snArr.push(con.productBrandSn)
+      //       snObjList.push(con)
+      //     })
+      //   }
+      // })
+      const dataList = _this.setShowData('Brand')
+      _this.openBrandModal = true
+      _this.chooseBrand = dataList[1]
+      _this.$refs.brandBox.handleDisabled(dataList[0])
     },
     handleBrandOk (conList) {
       const newConList = conList.map(con => {
@@ -273,6 +283,9 @@ export default {
     // 添加产品
     addProductTag (pos, row) {
       this.productTagIndex = pos
+      const dataList = this.setShowData('This')
+      debugger
+      this.chooseProducts = dataList[1]
       this.openProductsModal = true
     },
     handleProductsOk (arr) {
@@ -286,6 +299,27 @@ export default {
       })
       this.dataSource[this.productTagIndex].productThisList = newArr
     },
+    // 获取回显禁用数据
+    setShowData (name) {
+      const _this = this
+      const snArr = []
+      const snObjList = []
+      _this.dataSource.forEach(item => {
+        if (item['product' + name + 'List'] && item['product' + name + 'List'].length > 0) {
+          item['product' + name + 'List'].forEach(con => {
+            if (name === 'This') {
+              con.goodsSn = con.productSn
+              snArr.push(con.productSn)
+            } else {
+              con.goodsSn = con['product' + name + 'Sn']
+              snArr.push(con['product' + name + 'Sn'])
+            }
+            snObjList.push(con)
+          })
+        }
+      })
+      return [snArr, snObjList]
+    },
     getResultVal () {
       const resultObj = JSON.parse(JSON.stringify(this.dataSource))
       resultObj.map(item => {
@@ -295,6 +329,9 @@ export default {
       })
       return resultObj
     },
+    setTabVal (formData) {
+      this.dataSource = formData
+    },
     // 关闭时清空表格数据
     reSetTableData () {
       this.dataSource = []
@@ -307,7 +344,7 @@ export default {
         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)
+        const j = this.dataSource[pos].productBrandArr.findIndex(con => con.brandSn == row.brandSn)
         this.dataSource[pos].productBrandArr.splice(j, 1)
         this.dataSource[pos].productBrandList.splice(j, 1)
       } else {

+ 4 - 7
src/views/promotionRulesManagement/dealerPromotions/tableType2.vue

@@ -40,7 +40,7 @@
         <div style="max-height:106spx;overflow-y:scroll;">
           <a-row v-if="record.productBrandArr && record.productBrandArr.length>0">
             <a-col :span="20">
-              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.productScopeSn,item,'brandList')" v-for="item in record.productBrandArr" :key="item.productBrandSn">
+              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.productScopeSn,item,'brandList')" v-for="item in record.productBrandArr" :key="item.brandSn">
                 {{ item.brandName }}
               </a-tag>
             </a-col>
@@ -122,12 +122,6 @@ export default {
   name: 'TableType1',
   mixins: [commonMixin],
   components: { VSelect, ChooseBrandModal, ChooseTypeModal, chooseProductsModal },
-  props: {
-    itemSn: {
-      type: [Number, String],
-      default: ''
-    }
-  },
   data () {
     return {
       spinning: false,
@@ -263,6 +257,9 @@ export default {
       })
       return resultObj
     },
+    setTabVal (formData) {
+      this.dataSource = formData
+    },
     // 关闭时清空表格数据
     reSetTableData () {
       this.dataSource = []

+ 72 - 50
src/views/promotionRulesManagement/dealerPromotions/tableType3.vue

@@ -13,7 +13,7 @@
       bordered>
       <!-- 产品分类 -->
       <template slot="productType" slot-scope="text, record,index">
-        <div style="max-height:64px;overflow-y:scroll;" v-if="!record.dataSourceOrigin">
+        <div style="max-height:64px;overflow-y:scroll;" v-if="record.dataSourceOrigin=='0'">
           <a-row v-if="record.productTypeArr && record.productTypeArr.length>0">
             <a-col :span="20">
               <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.productScopeSn,con,'typeList')" v-for="con in record.productTypeArr" :key="con.id">
@@ -38,10 +38,10 @@
       </template>
       <!-- 品牌 -->
       <template slot="productBrand" slot-scope="text, record,index">
-        <div style="max-height:64px;overflow-y:scroll;" v-if="!record.dataSourceOrigin">
+        <div style="max-height:64px;overflow-y:scroll;" v-if="record.dataSourceOrigin=='0'">
           <a-row v-if="record.productBrandArr && record.productBrandArr.length>0">
             <a-col :span="20">
-              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.productScopeSn,item,'brandList')" v-for="item in record.productBrandArr" :key="item.productBrandSn">
+              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.productScopeSn,item,'brandList')" v-for="item in record.productBrandArr" :key="item.brandSn">
                 {{ item.brandName }}
               </a-tag>
             </a-col>
@@ -63,30 +63,31 @@
       </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-if="record.dataSourceOrigin=='1'" v-for="item in record.productThisList" :key="item.productSn">{{ item.productCode }}</span>
         <span v-else>--</span>
       </template>
       <!-- 省价特价 -->
       <template slot="provincePrice" slot-scope="text, record">
-        <a-input-number
-          size="small"
-          style="width:80%;"
-          v-model="record.provinceDiscountPrice"
-          :min="0"
-          :step="1"
-          :precision="2"
-          placeholder="请输入"
-          v-if="record.dataSourceOrigin"
-          :max="record.provincePrice"
-          @blur="e=>calculatePrice(e.target.value,record.productScopeSn,'province')"/>
+        <div v-if="record.dataSourceOrigin=='1'">
+          <a-input-number
+            size="small"
+            style="width:75%;"
+            v-model="record.provinceDiscountPrice"
+            :min="0"
+            :step="1"
+            :precision="2"
+            placeholder="请输入"
+            :max="record.provincePrice"
+            @blur="e=>calculatePrice(e.target.value,record.productScopeSn,'province')"/>
+        </div>
         <span v-else>--</span>
       </template>
       <!-- 省价折扣 -->
       <template slot="provinceDiscount" slot-scope="text, record">
-        <div v-if="!record.dataSourceOrigin">
+        <div v-if="record.dataSourceOrigin=='0'">
           <a-input-number
             size="small"
-            style="width:80%;"
+            style="width:75%;"
             v-model="record.provinceDiscountRate"
             :min="0"
             :step="1"
@@ -94,65 +95,67 @@
             placeholder="请输入"
           />%
         </div>
-        <span v-else>{{ record.provinceDiscountRate?record.provinceDiscountRate:'--' }}</span>
+        <span v-else>{{ record.provinceDiscountRate?record.provinceDiscountRate+'%':'--' }}</span>
       </template>
       <!-- 市价特价 -->
       <template slot="cityPrice" slot-scope="text, record">
-        <a-input-number
-          size="small"
-          style="width:80%;"
-          v-model="record.cityDiscountPrice"
-          :min="0"
-          :step="1"
-          :precision="2"
-          placeholder="请输入"
-          v-if="record.dataSourceOrigin"
-          :max="record.cityPrice"
-          @blur="e=>calculatePrice(e.target.value,record.productScopeSn,'city')"/>
+        <div  v-if="record.dataSourceOrigin=='1'">
+          <a-input-number
+            size="small"
+            style="width:75%;"
+            v-model="record.cityDiscountPrice"
+            :min="0"
+            :step="1"
+            :precision="2"
+            placeholder="请输入"
+            :max="record.cityPrice"
+            @blur="e=>calculatePrice(e.target.value,record.productScopeSn,'city')"/>
+        </div>
         <span v-else>--</span>
       </template>
       <!-- 市价折扣 -->
       <template slot="cityDiscount" slot-scope="text, record">
-        <div v-if="!record.dataSourceOrigin">
+        <div v-if="record.dataSourceOrigin=='0'">
           <a-input-number
             size="small"
-            style="width:80%;"
+            style="width:75%;"
             v-model="record.cityDiscountRate"
             :min="0"
             :step="1"
             :max="100"
             placeholder="请输入"/>%
         </div>
-        <span v-else>{{ record.cityDiscountRate?record.cityDiscountRate:'--' }}</span>
+        <span v-else>{{ record.cityDiscountRate?record.cityDiscountRate+'%':'--' }}</span>
       </template>
       <!-- 特约特价 -->
       <template slot="specialPrice" slot-scope="text, record">
-        <a-input-number
-          size="small"
-          style="width:80%;"
-          v-model="record.specialDiscountPrice"
-          :min="0"
-          :step="1"
-          :precision="2"
-          placeholder="请输入"
-          v-if="record.dataSourceOrigin"
-          :max="record.specialPrice"
-          @blur="e=>calculatePrice(e.target.value,record.productScopeSn,'special')"/>
+       <div  v-if="record.dataSourceOrigin=='1'">
+         <a-input-number
+           size="small"
+           style="width:75%;"
+           v-model="record.specialDiscountPrice"
+           :min="0"
+           :step="1"
+           :precision="2"
+           placeholder="请输入"
+           :max="record.specialPrice"
+           @blur="e=>calculatePrice(e.target.value,record.productScopeSn,'special')"/>
+       </div>
         <span v-else>--</span>
       </template>
       <!-- 特约折扣 -->
       <template slot="specialDiscount" slot-scope="text, record">
-        <div v-if="!record.dataSourceOrigin">
+        <div v-if="record.dataSourceOrigin=='0'">
           <a-input-number
             size="small"
-            style="width:80%;"
+            style="width:75%;"
             v-model="record.specialDiscountRate"
             :min="0"
             :step="1"
             :max="100"
-            placeholder="请输入"/>%
+            placeholder="请输入"/>
         </div>
-        <span v-else>{{ record.specialDiscountRate ? record.specialDiscountRate:'--' }}</span>
+        <span v-else>{{ record.specialDiscountRate ? record.specialDiscountRate+'%':'--' }}</span>
       </template>
       <!-- 设置起订量 -->
       <template slot="setNum" slot-scope="text, record">
@@ -239,7 +242,7 @@ export default {
       chooseType: [],
       brandTagIndex: null, // 所选品牌位置
       classifyTagIndex: null, // 所选分类位置
-      dataSourceOrigin: null // 数据来源  sle  选择产品  null 新增一行品类
+      dataSourceOrigin: 0 // 数据来源  1  选择产品  0 新增一行品类
     }
   },
   methods: {
@@ -248,14 +251,14 @@ export default {
       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 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
+      this.dataSource=this.dataSource.concat(list)
     },
     // 新增一行
     handleAddRow () {
@@ -265,6 +268,7 @@ export default {
         if (res.status == 200) {
           const newData = {
             productScopeSn: res.data,
+            dataSourceOrigin:'0',
             productTypeArr: [],
             productTypeList: [],
             productBrandArr: [],
@@ -276,6 +280,11 @@ export default {
         }
       })
     },
+    // 删除一行
+    handleDel (row) {
+      const pos = this.dataSource.findIndex(con => con.productScopeSn == row.productScopeSn)
+      this.dataSource.splice(pos, 1)
+    },
     // 添加产品分类
     addClassifyTag (pos, row) {
       this.classifyTagIndex = pos
@@ -351,6 +360,19 @@ export default {
     // 关闭时清空表格数据
     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)
+      }
     }
   }
 }