sendProductsModal.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. <template>
  2. <a-modal
  3. centered
  4. class="promotionList-basicInfo-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="规则设置"
  8. v-model="isShow"
  9. @cancel="isShow=false"
  10. width="70%">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <a-form-model
  13. id="promotionList-basicInfo-form"
  14. ref="ruleForm"
  15. :model="form"
  16. :rules="rules"
  17. :label-col="formItemLayout.labelCol"
  18. :wrapper-col="formItemLayout.wrapperCol" >
  19. <a-form-model-item label="规则简称" prop="description">
  20. <a-input
  21. size="small"
  22. id="promotionList-description"
  23. v-model.trim="form.description"
  24. allowClear
  25. placeholder="请输入规则简称(最多20个字符)"
  26. :maxLength="20"></a-input>
  27. </a-form-model-item>
  28. <a-form-model-item label="规则门槛" prop="gateFlag">
  29. <div class="fixWidthBox">
  30. <a-radio-group v-model="form.gateFlag" button-style="solid" size="small" @change="changeGateFlag">
  31. <a-radio-button value="1">
  32. </a-radio-button>
  33. <a-radio-button value="0">
  34. </a-radio-button>
  35. </a-radio-group>
  36. </div>
  37. <div v-if="form.gateFlag && form.gateFlag === '1'">
  38. <v-select
  39. size="small"
  40. style="width:60%;"
  41. v-model="form.gateType"
  42. id="promotionList-gateType"
  43. code="PROMOTION_GATE_TYPE"
  44. placeholder="请选择门槛与配额设置要求"
  45. @change="changeGateTypeFlag"
  46. allowClear></v-select>
  47. <div v-if="form.gateType==='RATIO_AMOUNT'">
  48. 购买门槛产品金额 <a-input-number v-model="form.gateValue" :min="0" :max="999999" :precision="2" size="small"/> %作为配额
  49. <a-tooltip title="如:填写100%,则购买10000元门槛产品,可享受10000配额购买正价产品,根据门槛金额动态调整配额">
  50. <a-icon type="question-circle" theme="filled" :style="{ fontSize: '14px', color: 'gray' }"/>
  51. </a-tooltip>
  52. </div>
  53. <div v-if="form.gateType==='MIN_AMOUNT'">
  54. 购买门槛产品满最低金额 <a-input-number v-model="form.gateValue" :min="0" :max="999999" :precision="2" size="small"/>元,不限制配额。
  55. </div>
  56. <div class="ruleDescList" v-if="form.gateType==='FIXED_AMOUNT'">
  57. 购买满
  58. <a-input-number v-model="form.gateValue" :min="0" :max="999999" :precision="2" size="small"/>
  59. 元门槛产品,可使用
  60. <a-input-number v-model="form.quotaAmount" :min="0" :max="999999" :precision="2" size="small"/>
  61. 元配额,采购规则中的正价商品(配额算销售额)
  62. </div>
  63. </div>
  64. </a-form-model-item>
  65. <a-form-model-item label="满赠规则" prop="regularSameFlag">
  66. <div class="fullGiftRuleBox">
  67. <div class="ruleDescList" v-for="(con,i) in fullGiftRuleList" :key="i">
  68. <span v-if="fullGiftRuleList.length>1">{{ i*1+1 }}、</span>
  69. <a-select
  70. default-value="1"
  71. :disabled="i!=0"
  72. v-model="form.regularSameFlag"
  73. style="width: 100px"
  74. size="small"
  75. @change="handleFullGift"
  76. allowClear>
  77. <a-select-option value="1">
  78. 同款
  79. </a-select-option>
  80. <a-select-option value="0">
  81. 不同款
  82. </a-select-option>
  83. </a-select>
  84. 产品购买满
  85. <a-input-number
  86. v-model="con.regularValue"
  87. :min="i!=0?fullGiftRuleList[i-1].regularValue:0"
  88. :step="1"
  89. :max="999999"
  90. :precision="form.regularUnit==='YUAN'?2:0"
  91. size="small"/>
  92. <a-select
  93. default-value="GE"
  94. :disabled="i!=0"
  95. v-model="form.regularUnit"
  96. style="width: 50px;margin-left:5px;"
  97. size="small"
  98. @change="handleChangeUnit">
  99. <a-select-option value="GE">
  100. </a-select-option>
  101. <a-select-option value="YUAN">
  102. </a-select-option>
  103. </a-select>
  104. 正价产品,送
  105. <a-input-number
  106. v-model="con.promotionValue"
  107. :min="0"
  108. :step="1"
  109. :precision="0"
  110. :max="999999"
  111. size="small"/>
  112. 个促销产品
  113. <a-button type="link" v-if="i==0&&fullGiftRuleList&&fullGiftRuleList.length<5" class="button-info" @click="addFullGiftRule">+新增</a-button>
  114. <a-button type="link" v-if="i!=0" class="button-error" @click="delFullGiftRule(con.id)">删除</a-button>
  115. </div>
  116. </div>
  117. <div class="ruleDescList">
  118. <a-checkbox :checked="form.restrictFlag === '1'" size="small" @change="onChange">
  119. 限制正价产品款数
  120. </a-checkbox>
  121. <a-input-number
  122. v-if="form.restrictFlag==='1'"
  123. v-model="form.restrictCategory"
  124. :min="0"
  125. :step="1"
  126. :max="999999"
  127. :precision="0"
  128. size="small"
  129. style="margin-right:10px;"/>
  130. <a-checkbox :checked="form.convertExpenseFlag==='1'" size="small" @change="onChangeConvert">
  131. 可转费用报销单
  132. </a-checkbox>
  133. </div>
  134. </a-form-model-item>
  135. <a-form-model-item label="数量叠加" prop="accrualFlag">
  136. <a-radio-group v-model="form.accrualFlag" button-style="solid" size="small">
  137. <a-radio value="1">
  138. </a-radio>
  139. <a-radio value="0">
  140. </a-radio>
  141. </a-radio-group>
  142. <span style="color:gray;">(如:满10送2,数量叠加则:满20送4,满30送6)</span>
  143. </a-form-model-item>
  144. <a-form-model-item label="促销品与正品一致" prop="regularPromotionSameFlag">
  145. <div class="fixWidthBox">
  146. <a-radio-group v-model="form.regularPromotionSameFlag" button-style="solid" size="small" :disabled="form.regularSameFlag==0" @change="handleSameFlag">
  147. <a-radio-button value="1">
  148. </a-radio-button>
  149. <a-radio-button value="0">
  150. </a-radio-button>
  151. </a-radio-group>
  152. </div>
  153. </a-form-model-item>
  154. </a-form-model>
  155. <a-card size="small" :bordered="false" class="pages-wrap">
  156. <div class="flex" style="margin-bottom:10px;">
  157. <a-radio-group v-model="chooseVal" button-style="solid" @change="onChooseVal">
  158. <a-radio-button value="a" v-show="form.gateFlag==='1'">
  159. 门槛产品
  160. </a-radio-button>
  161. <a-radio-button value="b">
  162. 正价产品
  163. </a-radio-button>
  164. <a-radio-button :value="'c'+item.id" v-for="(item,i) in fullGiftRuleList" :key="i" v-show="form.regularPromotionSameFlag==='0'">
  165. {{ fullGiftRuleList.length>1?'促销产品('+'阶梯'+(i*1+1)+')':'促销产品' }}
  166. </a-radio-button>
  167. </a-radio-group>
  168. <a-button
  169. size="small"
  170. type="link"
  171. class="button-info"
  172. @click="openGuideModal=true"
  173. id="promotionList-edit-btn">+导入产品</a-button>
  174. </div>
  175. <div v-show="chooseVal=='a'"><tableType1 :unitTypeList="unitTypeDataList" ref="cillProduct"></tableType1></div>
  176. <div v-show="chooseVal=='b'"><tableType1 :unitTypeList="unitTypeDataList" ref="normalPriceProduct"></tableType1></div>
  177. <div v-show="chooseVal==('c'+item.id)" v-for="(item,i) in fullGiftRuleList" :key="item.id"><tableType1 :unitTypeList="unitTypeDataList" :ref="'offerProduct'+i"></tableType1></div>
  178. </a-card>
  179. <div class="btn-cont">
  180. <a-button id="promotionList-basicInfo-modal-back" @click="isShow = false">取消</a-button>
  181. <a-button style="margin-left: 15px;" type="primary" id="promotionList-modal-save" :loading="loadingSave" @click="handleSave">确定</a-button>
  182. </div>
  183. </a-spin>
  184. <!-- 导入产品 -->
  185. <importGuideModal goodFlag="1" :openModal="openGuideModal" @close="closeGuideModel" @ok="hanldeOk" />
  186. </a-modal>
  187. </template>
  188. <script>
  189. import { commonMixin } from '@/utils/mixin'
  190. import { VSelect } from '@/components'
  191. import tableType1 from './tableType1.vue'
  192. import { promotionSave, getRuleDetail, getNewScopeSn } from '@/api/promotion'
  193. import ImportGuideModal from './importGuideModal.vue'
  194. import { getLookUpData } from '@/api/data'
  195. export default {
  196. name: 'PromotionListBasicInfoModal',
  197. mixins: [commonMixin],
  198. components: { VSelect, tableType1, ImportGuideModal },
  199. props: {
  200. openModal: { // 弹框显示状态
  201. type: Boolean,
  202. default: false
  203. },
  204. promotionSn: {
  205. type: [Number, String],
  206. default: ''
  207. },
  208. itemSn: {
  209. type: [Number, String],
  210. default: ''
  211. }
  212. },
  213. data () {
  214. return {
  215. isShow: this.openModal, // 是否打开弹框
  216. spinning: false,
  217. formItemLayout: {
  218. labelCol: { span: 4 },
  219. wrapperCol: { span: 17 }
  220. },
  221. fullGiftRuleList: [{
  222. id: undefined,
  223. scopeLevel: undefined,
  224. regularValue: undefined,
  225. promotionValue: undefined
  226. }],
  227. form: {
  228. giveRuleType: 'RATIO', // 满赠规则类型: SUM_MONEY[金额叠加] / RATIO[按比例] 满产品送产品写死为: 按比例
  229. promotionRuleType: 'BUY_PROD_GIVE_PROD', // 买产品送产品
  230. description: '', // 简称
  231. gateFlag: '0', // 门槛
  232. gateType: undefined,
  233. gateValue: undefined,
  234. quotaAmount: undefined,
  235. regularSameFlag: '1', // 满赠规则 同款不同款商品
  236. regularUnit: 'GE',
  237. restrictFlag: '0', // 限制正价产品款数
  238. convertExpenseFlag: '0', // 转费用报销标记
  239. restrictCategory: '',
  240. accrualFlag: '1', // 数量叠加
  241. regularPromotionSameFlag: '1',
  242. giftProductMap: {},
  243. gateInfo: undefined,
  244. ruleInfo: undefined,
  245. gateUnit: undefined,
  246. quotaUnit: undefined
  247. },
  248. rules: {
  249. description: [ { required: true, message: '请输入规则简称', trigger: 'blur' } ],
  250. gateFlag: [ { required: true, message: '请选择规则门槛', trigger: 'change' } ],
  251. regularSameFlag: [{ required: true, message: '请选择满赠规则', trigger: 'change' }],
  252. accrualFlag: [{ required: true, message: '请选择数量是否叠加', trigger: 'change' }],
  253. regularPromotionSameFlag: [{ required: true, message: '请选择促销品与正品是否一致', trigger: 'change' }]
  254. },
  255. chooseVal: 'a',
  256. openGuideModal: false, // 导入弹窗
  257. id: null,
  258. code: 'SCOPE_UNIT_TYPE', // 起订类型数据字典
  259. unitTypeDataList: [],
  260. loadingSave: false
  261. }
  262. },
  263. methods: {
  264. // 单位切换时,满赠规则数据清空
  265. handleChangeUnit (e) {
  266. this.form.regularUnit = e
  267. this.fullGiftRuleList.forEach(item => {
  268. item.regularValue = undefined
  269. })
  270. },
  271. onChooseVal (e) {
  272. this.chooseVal = e.target.value
  273. },
  274. // 新增 满减规则 最多能添加五个
  275. async addFullGiftRule () {
  276. const result = await getNewScopeSn({})
  277. const obj = {
  278. id: result.data,
  279. scopeLevel: undefined,
  280. regularValue: undefined,
  281. promotionValue: undefined
  282. }
  283. this.fullGiftRuleList.push(obj)
  284. },
  285. // 删除满减规则
  286. delFullGiftRule (id) {
  287. const pos = this.fullGiftRuleList.findIndex(con => { return con.id == id })
  288. this.fullGiftRuleList.splice(pos, 1)
  289. if (this.chooseVal == 'c' + id) {
  290. this.chooseVal = this.form.gateFlag == '0' ? 'b' : 'a'
  291. }
  292. },
  293. // 满赠 同款 促销品与正品一致 默认是 可修改
  294. // 不同款 默认否 不可修改
  295. handleFullGift (e) {
  296. if (e === '0') { // 不同款
  297. this.form.regularPromotionSameFlag = '0'
  298. } else {
  299. this.form.regularPromotionSameFlag = '1'
  300. if (this.chooseVal.indexOf('c') != -1) {
  301. this.chooseVal = this.form.gateFlag == '0' ? 'b' : 'a'
  302. }
  303. }
  304. },
  305. // 导入
  306. closeGuideModel () {
  307. this.openGuideModal = false
  308. },
  309. hanldeOk (arr) {
  310. if (this.chooseVal == 'a') {
  311. this.$refs['cillProduct'].importRow(arr)
  312. } else if (this.chooseVal == 'b') {
  313. this.$refs['normalPriceProduct'].importRow(arr)
  314. } else {
  315. const pos = this.fullGiftRuleList.findIndex(item => { return 'c' + item.id == this.chooseVal })
  316. if (pos != -1) {
  317. this.$refs['offerProduct' + pos][0].importRow(arr)
  318. }
  319. }
  320. },
  321. // 限制正价产品款数
  322. onChange (e) {
  323. this.form.restrictFlag = e.target.checked ? '1' : '0'
  324. },
  325. onChangeConvert (e) {
  326. this.form.convertExpenseFlag = e.target.checked ? '1' : '0'
  327. },
  328. // 门槛切换 tab 按钮默认显示问题
  329. changeGateFlag (e) {
  330. if (e.target.value == '0') {
  331. this.chooseVal = 'b'
  332. this.form.gateType = undefined
  333. this.form.gateValue = undefined
  334. this.form.quotaAmount = undefined
  335. } else {
  336. this.chooseVal = 'a'
  337. }
  338. },
  339. handleSameFlag (e) {
  340. if (e.target.value != '0') {
  341. this.chooseVal = this.form.gateFlag == '1' ? 'a' : 'b'
  342. }
  343. },
  344. changeGateTypeFlag (val) {
  345. this.form.gateType = val
  346. this.form.gateValue = undefined
  347. this.form.quotaAmount = undefined
  348. },
  349. // 保存
  350. handleSave () {
  351. const _this = this
  352. this.$refs.ruleForm.validate(valid => {
  353. if (valid) {
  354. // 验证必填
  355. if (_this.form.gateFlag == '1') {
  356. if (!_this.form.gateType) {
  357. _this.$message.warning('请选择规则门槛设置类型!')
  358. return
  359. }
  360. if (!_this.form.gateValue) {
  361. _this.$message.warning('规则门槛条件不能为空!')
  362. return
  363. }
  364. if (_this.form.gateType === 'FIXED_AMOUNT' && !_this.form.quotaAmount) {
  365. _this.$message.warning('规则门槛条件不能为空!')
  366. return
  367. }
  368. if (_this.form.gateType == 'RATIO_AMOUNT') {
  369. _this.form.gateUnit = 'RATIO'
  370. } else if (_this.form.gateType == 'MIN_AMOUNT') {
  371. _this.form.gateUnit = 'YUAN'
  372. } else {
  373. _this.form.gateUnit = 'YUAN'
  374. _this.form.quotaUnit = 'YUAN'
  375. }
  376. }
  377. const hasNullVal = _this.fullGiftRuleList.some(itemVal => {
  378. if (itemVal.regularValue && itemVal.promotionValue) {
  379. return (itemVal.regularValue <= 0 || itemVal.promotionValue <= 0)
  380. } else {
  381. return true
  382. }
  383. })
  384. if (hasNullVal) {
  385. _this.$message.warning('满赠规则条件不能为空!')
  386. return
  387. }
  388. if (_this.form.restrictFlag === '1' && !_this.form.restrictCategory) {
  389. _this.$message.warning('请输入限制正价产品款数个数!')
  390. return
  391. }
  392. var form = JSON.parse(JSON.stringify(_this.form))
  393. let rowFlag1, rowFlag2, rowFlag3
  394. if (form.gateFlag == '1') { // 门槛产品
  395. form.gateProductList = this.$refs.cillProduct.getResultVal()
  396. form.gateValue = form.gateType === 'RATIO_AMOUNT' ? form.gateValue / 100 : form.gateValue
  397. if (form.gateProductList.length == 0) {
  398. _this.$message.warning('请添加门槛产品!')
  399. return
  400. } else {
  401. const qtyFlag = form.gateProductList.some(newCon => { return (!newCon.unitType || !newCon.unitQty) })
  402. if (qtyFlag) {
  403. _this.$message.warning('订单起订量设置不能为空!')
  404. return
  405. }
  406. rowFlag1 = _this.isJudge(form.gateProductList)
  407. }
  408. } else {
  409. form.gateProductList = []
  410. form.gateType = undefined
  411. }
  412. // 正价产品
  413. form.regularProductList = this.$refs.normalPriceProduct.getResultVal()
  414. // 判断表格必填
  415. if (form.regularProductList.length == 0) {
  416. _this.$message.warning('请添加正价产品!')
  417. return
  418. } else {
  419. const qtyFlag = form.regularProductList.some(newCon => { return (!newCon.unitType || !newCon.unitQty) })
  420. if (qtyFlag) {
  421. _this.$message.warning('订单起订量设置不能为空!')
  422. return
  423. }
  424. rowFlag2 = _this.isJudge(form.regularProductList)
  425. }
  426. if (form.regularPromotionSameFlag === '0') { // 促销产品 阶梯促销产品
  427. const allGiftObj = {}
  428. _this.fullGiftRuleList.forEach((val, i) => {
  429. allGiftObj['GIFT' + (i * 1 + 1)] = _this.$refs['offerProduct' + i][0].getResultVal()
  430. })
  431. var lengthFlag = null
  432. for (const key in allGiftObj) {
  433. if (allGiftObj[key].length === 0) {
  434. lengthFlag = true
  435. }
  436. }
  437. if (lengthFlag) {
  438. _this.$message.warning('请添加促销产品!')
  439. return
  440. }
  441. const arrFlag = []
  442. for (const key in allGiftObj) {
  443. if (allGiftObj[key] && allGiftObj[key].length > 0) {
  444. arrFlag.push(_this.isJudge(allGiftObj[key]))
  445. }
  446. }
  447. rowFlag3 = arrFlag.some(val => { return val })
  448. // 组数据,添加数组标识
  449. let keyPos = 0
  450. for (const key in allGiftObj) {
  451. keyPos += 1
  452. allGiftObj[key].forEach((item, j) => {
  453. item.scopeLevel = keyPos
  454. })
  455. }
  456. form.giftProductMap = allGiftObj
  457. } else {
  458. form.giftProductMap = {}
  459. }
  460. if (rowFlag1 || rowFlag2 || rowFlag3) {
  461. _this.$message.warning('请选择产品分类、品牌或产品!')
  462. return
  463. }
  464. // 组传给后台所需数据
  465. _this.fullGiftRuleList.map((val, i) => {
  466. val.scopeLevel = i * 1 + 1
  467. val.regularSameFlag = form.regularSameFlag
  468. val.regularUnit = form.regularUnit
  469. })
  470. form.promotionSn = _this.promotionSn
  471. form.giveRuleList = _this.fullGiftRuleList
  472. if (form.gateFlag == '1') {
  473. if (form.gateType === 'RATIO_AMOUNT') {
  474. form.gateInfo = '购买门槛产品金额' + (form.gateValue * 100).toFixed(2) + '%作为配额'
  475. } else if (form.gateType === 'MIN_AMOUNT') {
  476. form.gateInfo = '购买门槛产品满最低金额' + form.gateValue + '不限制配额'
  477. } else {
  478. form.gateInfo = '购买满' + form.gateValue + '元门槛产品,可使用' + form.quotaAmount + '元配额,采购规则中的正价商品(配额算销售额)'
  479. }
  480. }
  481. var newInfo = `<div>${form.accrualFlag == '1' ? '数量叠加;' : ''}${form.convertExpenseFlag == '1' ? '可转费用报销单;' : ''}</div>`
  482. _this.fullGiftRuleList.forEach((item, i) => {
  483. newInfo += `<div>${_this.fullGiftRuleList.length > 1 ? (i * 1 + 1) + '、' : ''}${form.regularSameFlag == '1' ? '同款' : '不同款'}产品购买满${item.regularValue}${form.regularUnit == 'YUAN' ? '元' : '个'}正价产品,送${item.promotionValue}个促销产品</div>`
  484. })
  485. newInfo += form.restrictFlag == '1' ? `<div>限制正价产品${form.restrictCategory}款</div>` : ''
  486. form.ruleInfo = newInfo
  487. _this.spinning = true
  488. _this.loadingSave = true
  489. promotionSave(form).then(res => {
  490. if (res.status == 200) {
  491. _this.$message.success(res.message)
  492. setTimeout(() => {
  493. _this.isShow = false
  494. _this.$emit('ok')
  495. _this.spinning = false
  496. _this.loadingSave = false
  497. }, 1000)
  498. } else {
  499. _this.spinning = false
  500. _this.loadingSave = false
  501. }
  502. })
  503. } else {
  504. return false
  505. }
  506. })
  507. },
  508. // 判断品牌,分类,产品其中一个必填
  509. isJudge (list) {
  510. let flag = null
  511. list.forEach(con => {
  512. if (con.productThisList) {
  513. if (con.productThisList.length > 0) {
  514. flag = false
  515. } else {
  516. if ((con.productTypeList && con.productTypeList.length > 0) || (con.productBrandList && con.productBrandList.length > 0)) {
  517. flag = false
  518. } else {
  519. flag = true
  520. }
  521. }
  522. } else {
  523. if ((con.productTypeList && con.productTypeList.length > 0) || (con.productBrandList && con.productBrandList.length > 0)) {
  524. flag = false
  525. } else {
  526. flag = true
  527. }
  528. }
  529. })
  530. return flag
  531. },
  532. // 重置表格
  533. async resetSearchForm () {
  534. this.form = {
  535. giveRuleType: 'RATIO', // 满赠规则类型: SUM_MONEY[金额叠加] / RATIO[按比例] 满产品送产品写死为: 按比例
  536. promotionRuleType: 'BUY_PROD_GIVE_PROD', // 买产品送产品
  537. description: '', // 简称
  538. gateFlag: '0', // 门槛
  539. gateType: undefined,
  540. gateValue: undefined,
  541. quotaAmount: undefined,
  542. regularSameFlag: '1', // 满赠规则 同款不同款商品
  543. regularUnit: 'GE',
  544. restrictFlag: '0', // 限制正价产品款数
  545. convertExpenseFlag: '0', // 转费用报销标记
  546. restrictCategory: '',
  547. accrualFlag: '1', // 数量叠加
  548. regularPromotionSameFlag: '1',
  549. giftProductMap: {},
  550. gateProductList: undefined,
  551. regularProductList: undefined,
  552. gateInfo: undefined,
  553. ruleInfo: undefined,
  554. gateUnit: undefined,
  555. quotaUnit: undefined
  556. }
  557. this.$nextTick(() => {
  558. this.$refs.ruleForm.resetFields()
  559. this.$refs.cillProduct.reSetTableData()
  560. this.$refs.normalPriceProduct.reSetTableData()
  561. })
  562. this.fullGiftRuleList.forEach((val, i) => {
  563. this.$refs['offerProduct' + i][0].reSetTableData()
  564. })
  565. const result = await getNewScopeSn({})
  566. this.fullGiftRuleList = [{
  567. id: result.data,
  568. regularValue: undefined,
  569. promotionValue: undefined
  570. }]
  571. this.id = null
  572. },
  573. // 获取编辑详情
  574. getDetail () {
  575. const _this = this
  576. getRuleDetail({ sn: _this.itemSn }).then(res => {
  577. if (res.status == 200) {
  578. const resultObj = res.data
  579. _this.chooseVal = resultObj.gateFlag == '0' ? 'b' : 'a'
  580. if (resultObj.gateFlag == '1') {
  581. resultObj.gateValue = resultObj.gateType === 'RATIO_AMOUNT' ? resultObj.gateValue * 100 : resultObj.gateValue
  582. }
  583. if (resultObj.giveRuleList && resultObj.giveRuleList.length > 0) {
  584. _this.fullGiftRuleList = resultObj.giveRuleList
  585. _this.$nextTick(() => {
  586. resultObj.giveRuleList.forEach((item, i) => {
  587. _this.$refs['offerProduct' + i][0].setTabVal(_this.newData(resultObj.giftProductMap['GIFT' + (i * 1 + 1)]))
  588. })
  589. })
  590. }
  591. // 重新组成保存数据
  592. if (resultObj.gateProductList && resultObj.gateProductList.length > 0) {
  593. resultObj.gateProductList = _this.newData(resultObj.gateProductList)
  594. _this.$refs.cillProduct.setTabVal(resultObj.gateProductList)
  595. }
  596. if (resultObj.regularProductList && resultObj.regularProductList.length > 0) {
  597. resultObj.regularProductList = _this.newData(resultObj.regularProductList)
  598. _this.$refs.normalPriceProduct.setTabVal(resultObj.regularProductList)
  599. }
  600. const newDataObj = { ..._this.form, ...resultObj }
  601. delete newDataObj.giftProductList
  602. _this.form = newDataObj
  603. }
  604. })
  605. },
  606. newData (list) {
  607. list.forEach(con => {
  608. // 品牌
  609. if (con.productBrandList) {
  610. const brandList = []
  611. con.productBrandList.forEach(item => {
  612. item.brandName = item.productBrandName
  613. const brandObj = {
  614. productBrandSn: item.productBrandSn
  615. }
  616. brandList.push(brandObj)
  617. })
  618. con.productBrandArr = con.productBrandList
  619. con.productBrandList = brandList
  620. }
  621. // 分类
  622. if (con.productTypeList) {
  623. const typeList = []
  624. con.productTypeList.forEach(item => {
  625. const typeObj = {}
  626. const num = 3
  627. for (var i = 0; i < num; i++) {
  628. if (item['productTypeName' + (i + 1)]) {
  629. typeObj['productTypeSn' + (i + 1)] = item['productTypeSn' + (i + 1)] ? item['productTypeSn' + (i + 1)] : ''
  630. }
  631. }
  632. if (item.productTypeName3) {
  633. item.title = item.productTypeName2 + '/' + item.productTypeName3
  634. } else if (!item.productTypeName3 && item.productTypeName2) {
  635. item.title = item.productTypeName2
  636. } else {
  637. item.title = item.productTypeName1
  638. }
  639. item.id = item.productTypeSn3 ? item.productTypeSn3 : item.productTypeSn2 ? item.productTypeSn2 : item.productTypeSn1
  640. typeList.push(typeObj)
  641. })
  642. con.productTypeArr = con.productTypeList
  643. con.productTypeList = typeList
  644. }
  645. // 产品
  646. if (con.productThisList) {
  647. const productList = []
  648. con.productThisList.forEach(item => {
  649. const productObj = {
  650. productCode: item.productCode,
  651. productSn: item.productSn
  652. }
  653. productList.push(productObj)
  654. })
  655. con.productThisList = productList
  656. }
  657. })
  658. return list
  659. },
  660. getUnitTypeList () {
  661. const _this = this
  662. getLookUpData({
  663. pageNo: 1,
  664. pageSize: 1000,
  665. lookupCode: _this.code
  666. }).then(res => {
  667. if (res.status == 200) {
  668. _this.unitTypeDataList = res.data.list
  669. }
  670. })
  671. }
  672. },
  673. watch: {
  674. // 父页面传过来的弹框状态
  675. openModal (newValue, oldValue) {
  676. this.isShow = newValue
  677. },
  678. // 重定义的弹框状态
  679. isShow (newValue, oldValue) {
  680. if (!newValue) {
  681. this.$emit('close')
  682. this.resetSearchForm()
  683. } else {
  684. // 获取起订类型数据字典
  685. this.getUnitTypeList()
  686. if (this.itemSn) {
  687. this.getDetail()
  688. } else {
  689. this.chooseVal = this.form.gateFlag == '0' ? 'b' : 'a'
  690. }
  691. }
  692. }
  693. }
  694. }
  695. </script>
  696. <style lang="less" scoped>
  697. .promotionList-basicInfo-modal{
  698. /deep/.ant-modal-body {
  699. padding: 20px 30px;
  700. max-height: 745px !important;
  701. overflow-y: scroll !important;
  702. }
  703. .fixWidthBox .ant-radio-button-wrapper{
  704. width:80px;
  705. text-align: center;
  706. }
  707. .ant-form-item{
  708. margin-bottom:5px;
  709. }
  710. .buyerBox{
  711. border:1px solid #d9d9d9;margin-top:10px;border-radius:4px;padding:4px 10px;background:#f2f2f2;max-height:130px;overflow-y:scroll;
  712. }
  713. .btn-cont {
  714. text-align: center;
  715. margin: 35px 0 10px;
  716. }
  717. .flex{
  718. display:flex;
  719. align-items:center;
  720. justify-content:space-between;
  721. }
  722. .ant-radio-button-wrapper-disabled.ant-radio-button-wrapper-checked{
  723. background-color: #ed1c24 !important;
  724. }
  725. }
  726. /deep/.ve-table{
  727. border-radius:5px;
  728. }
  729. </style>