sendProductsModal.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  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">
  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">
  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'+i" 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 ref="cillProduct"></tableType1></div>
  176. <div v-show="chooseVal=='b'"><tableType1 ref="normalPriceProduct"></tableType1></div>
  177. <div v-show="chooseVal==('c'+i)" v-for="(item,i) in fullGiftRuleList" :key="item.id"><tableType1 :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" @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 } from '@/api/promotion'
  193. import ImportGuideModal from './importGuideModal.vue'
  194. export default {
  195. name: 'PromotionListBasicInfoModal',
  196. mixins: [commonMixin],
  197. components: { VSelect, tableType1, ImportGuideModal },
  198. props: {
  199. openModal: { // 弹框显示状态
  200. type: Boolean,
  201. default: false
  202. },
  203. promotionSn: {
  204. type: [Number, String],
  205. default: ''
  206. },
  207. itemSn: {
  208. type: [Number, String],
  209. default: ''
  210. }
  211. },
  212. data () {
  213. return {
  214. isShow: this.openModal, // 是否打开弹框
  215. spinning: false,
  216. formItemLayout: {
  217. labelCol: { span: 4 },
  218. wrapperCol: { span: 17 }
  219. },
  220. fullGiftRuleList: [{
  221. id: this.generateRandomString(),
  222. scopeLevel: undefined,
  223. regularValue: undefined,
  224. promotionValue: undefined
  225. }],
  226. form: {
  227. giveRuleType: 'RATIO', // 满赠规则类型: SUM_MONEY[金额叠加] / RATIO[按比例] 满产品送产品写死为: 按比例
  228. promotionRuleType: 'BUY_PROD_GIVE_PROD', // 买产品送产品
  229. description: '', // 简称
  230. gateFlag: '0', // 门槛
  231. gateType: undefined,
  232. gateValue: undefined,
  233. quotaAmount: undefined,
  234. regularSameFlag: '1', // 满赠规则 同款不同款商品
  235. regularUnit: 'GE',
  236. restrictFlag: '0', // 限制正价产品款数
  237. convertExpenseFlag: '0', // 转费用报销标记
  238. restrictCategory: '',
  239. accrualFlag: '1', // 数量叠加
  240. regularPromotionSameFlag: '1',
  241. giftProductMap: {},
  242. gateInfo: undefined,
  243. ruleInfo: undefined
  244. },
  245. rules: {
  246. description: [ { required: true, message: '请输入规则简称', trigger: 'blur' } ],
  247. gateFlag: [ { required: true, message: '请选择规则门槛', trigger: 'change' } ],
  248. regularSameFlag: [{ required: true, message: '请选择满赠规则', trigger: 'change' }],
  249. accrualFlag: [{ required: true, message: '请选择数量是否叠加', trigger: 'change' }],
  250. regularPromotionSameFlag: [{ required: true, message: '请选择促销品与正品是否一致', trigger: 'change' }]
  251. },
  252. chooseVal: 'a',
  253. openGuideModal: false, // 导入弹窗
  254. id: ''
  255. }
  256. },
  257. methods: {
  258. // 生成随机id
  259. generateRandomString () {
  260. const result = new Date().getTime() + 'IDNUM'
  261. return result
  262. },
  263. // 单位切换时,满赠规则数据清空
  264. handleChangeUnit (e) {
  265. this.form.regularUnit = e
  266. this.fullGiftRuleList.forEach(item => {
  267. item.regularValue = undefined
  268. })
  269. },
  270. onChooseVal (e) {
  271. this.chooseVal = e.target.value
  272. },
  273. // 新增 满减规则 最多能添加五个
  274. addFullGiftRule () {
  275. this.id = this.generateRandomString()
  276. const obj = {
  277. id: this.id,
  278. scopeLevel: undefined,
  279. regularValue: undefined,
  280. promotionValue: undefined
  281. }
  282. this.fullGiftRuleList.push(obj)
  283. debugger
  284. },
  285. // 删除满减规则
  286. delFullGiftRule (id) {
  287. const pos = this.fullGiftRuleList.findIndex(con => { return con.id == id })
  288. this.fullGiftRuleList.splice(pos, 1)
  289. this.chooseVal = this.form.gateFlag == '0' ? 'b' : 'a'
  290. },
  291. // 满赠 同款 促销品与正品一致 默认是 可修改
  292. // 不同款 默认否 不可修改
  293. handleFullGift (e) {
  294. if (e === '0') {
  295. this.form.regularPromotionSameFlag = '0'
  296. } else {
  297. this.form.regularPromotionSameFlag = '1'
  298. }
  299. },
  300. // 导入
  301. closeGuideModel () {
  302. this.openGuideModal = false
  303. },
  304. hanldeOk (arr) {
  305. const name = this.chooseVal == 'a' ? 'cill' : this.chooseVal == 'b' ? 'normalPrice' : 'offer'
  306. this.$refs[name + 'Product'].importRow(arr)
  307. },
  308. // 限制正价产品款数
  309. onChange (e) {
  310. this.form.restrictFlag = e.target.checked ? '1' : '0'
  311. },
  312. onChangeConvert (e) {
  313. this.form.convertExpenseFlag = e.target.checked ? '1' : '0'
  314. },
  315. // 门槛切换 tab 按钮默认显示问题
  316. changeGateFlag (e) {
  317. if (e.target.value == '0') {
  318. this.chooseVal = 'b'
  319. this.form.gateType = undefined
  320. this.form.gateValue = undefined
  321. this.form.quotaAmount = undefined
  322. } else {
  323. this.chooseVal = 'a'
  324. }
  325. },
  326. changeGateTypeFlag (val) {
  327. this.form.gateType = val
  328. this.form.gateValue = undefined
  329. this.form.quotaAmount = undefined
  330. },
  331. // 保存
  332. handleSave () {
  333. const _this = this
  334. this.$refs.ruleForm.validate(valid => {
  335. if (valid) {
  336. // 验证必填
  337. if (_this.form.gateFlag == '1') {
  338. if (!_this.form.gateType) {
  339. _this.$message.warning('请选择规则门槛设置类型!')
  340. return
  341. }
  342. if (!_this.form.gateValue) {
  343. _this.$message.warning('规则门槛条件不能为空!')
  344. return
  345. }
  346. if (_this.form.gateType === 'FIXED_AMOUNT' && !_this.form.quotaAmount) {
  347. _this.$message.warning('规则门槛条件不能为空!')
  348. return
  349. }
  350. }
  351. const hasNullVal = _this.fullGiftRuleList.some(itemVal => (itemVal.regularValue <= 0 || itemVal.promotionValue <= 0))
  352. if (hasNullVal) {
  353. _this.$message.warning('满赠规则条件不能为空!')
  354. return
  355. }
  356. if (_this.form.restrictFlag === '1' && !_this.form.restrictCategory) {
  357. _this.$message.warning('请输入限制正价产品款数个数!')
  358. return
  359. }
  360. var form = JSON.parse(JSON.stringify(_this.form))
  361. let rowFlag1, rowFlag2, rowFlag3
  362. if (form.gateFlag == '1') { // 门槛产品
  363. form.gateProductList = this.$refs.cillProduct.getResultVal()
  364. form.gateValue = form.gateType === 'RATIO_AMOUNT' ? form.gateValue / 100 : form.gateValue
  365. if (form.gateProductList.length == 0) {
  366. _this.$message.warning('请添加门槛产品!')
  367. return
  368. } else {
  369. const qtyFlag = form.gateProductList.some(newCon => { return (!newCon.unitType || !newCon.unitQty) })
  370. if (qtyFlag) {
  371. _this.$message.warning('订单起订量设置不能为空!')
  372. return
  373. }
  374. rowFlag1 = _this.isJudge(form.gateProductList)
  375. }
  376. } else {
  377. form.gateProductList = []
  378. form.gateType = undefined
  379. }
  380. // 正价产品
  381. form.regularProductList = this.$refs.normalPriceProduct.getResultVal()
  382. // 判断表格必填
  383. if (form.regularProductList.length == 0) {
  384. _this.$message.warning('请添加正价产品!')
  385. return
  386. } else {
  387. const qtyFlag = form.regularProductList.some(newCon => { return (!newCon.unitType || !newCon.unitQty) })
  388. if (qtyFlag) {
  389. _this.$message.warning('订单起订量设置不能为空!')
  390. return
  391. }
  392. rowFlag2 = _this.isJudge(form.regularProductList)
  393. }
  394. if (form.regularPromotionSameFlag === '0') { // 促销产品 阶梯促销产品
  395. const allGiftObj = {}
  396. _this.fullGiftRuleList.forEach((val, i) => {
  397. allGiftObj['GIFT' + (i * 1 + 1)] = _this.$refs['offerProduct' + i][0].getResultVal()
  398. })
  399. var lengthFlag = null
  400. for (const key in allGiftObj) {
  401. if (allGiftObj[key].length === 0) {
  402. lengthFlag = true
  403. }
  404. }
  405. if (lengthFlag) {
  406. _this.$message.warning('请添加促销产品!')
  407. return
  408. }
  409. const arrFlag = []
  410. for (const key in allGiftObj) {
  411. if (allGiftObj[key] && allGiftObj[key].length > 0) {
  412. arrFlag.push(_this.isJudge(allGiftObj[key]))
  413. }
  414. }
  415. rowFlag3 = arrFlag.some(val => { return val })
  416. // 组数据,添加数组标识
  417. let keyPos = 0
  418. for (const key in allGiftObj) {
  419. keyPos += 1
  420. allGiftObj[key].forEach((item, j) => {
  421. item.scopeLevel = keyPos
  422. })
  423. }
  424. form.giftProductMap = allGiftObj
  425. } else {
  426. form.giftProductMap = {}
  427. }
  428. if (rowFlag1 || rowFlag2 || rowFlag3) {
  429. _this.$message.warning('请选择产品分类、品牌或产品!')
  430. return
  431. }
  432. // 组传给后台所需数据
  433. _this.fullGiftRuleList.map((val, i) => {
  434. val.scopeLevel = i * 1 + 1
  435. val.regularSameFlag = form.regularSameFlag
  436. val.regularUnit = form.regularUnit
  437. })
  438. form.promotionSn = _this.promotionSn
  439. form.giveRuleList = _this.fullGiftRuleList
  440. if (form.gateFlag == '1') {
  441. if (form.gateType === 'RATIO_AMOUNT') {
  442. form.gateInfo = '购买门槛产品金额' + form.gateValue + '作为配额'
  443. } else if (form.gateType === 'MIN_AMOUNT') {
  444. form.gateInfo = '购买门槛产品满最低金额' + form.gateValue + '不限制配额'
  445. } else {
  446. form.gateInfo = '购买满' + form.gateValue + '元门槛产品,可使用' + form.quotaAmount + '元配额,采购规则中的正价商品(配额算销售额)'
  447. }
  448. }
  449. var newInfo = `<div>${form.accrualFlag == '1' ? '数量叠加;' : ''}${form.convertExpenseFlag == '1' ? '可转费用报销单;' : ''}</div>`
  450. _this.fullGiftRuleList.forEach(item => {
  451. newInfo += `<div>${form.regularSameFlag == '1' ? '同款' : '不同款'}产品购买满${item.regularValue}${form.regularUnit == 'YUAN' ? '元' : '个'}正价产品,送${item.promotionValue}个促销产品</div>`
  452. })
  453. newInfo += form.restrictFlag == '1' ? `<div>限制正价产品${form.restrictCategory}款</div>` : ''
  454. form.ruleInfo = newInfo
  455. _this.spinning = true
  456. promotionSave(form).then(res => {
  457. if (res.status == 200) {
  458. _this.$message.success(res.message)
  459. setTimeout(() => {
  460. _this.isShow = false
  461. _this.$emit('ok')
  462. _this.spinning = false
  463. }, 1000)
  464. } else {
  465. _this.spinning = false
  466. }
  467. })
  468. } else {
  469. return false
  470. }
  471. })
  472. },
  473. // 判断品牌,分类,产品其中一个必填
  474. isJudge (list) {
  475. let flag = null
  476. list.forEach(con => {
  477. if (con.productThisList) {
  478. if (con.productThisList.length > 0) {
  479. flag = false
  480. } else {
  481. if ((con.productTypeList && con.productTypeList.length > 0) || (con.productBrandList && con.productBrandList.length > 0)) {
  482. flag = false
  483. } else {
  484. flag = true
  485. }
  486. }
  487. } else {
  488. if ((con.productTypeList && con.productTypeList.length > 0) || (con.productBrandList && con.productBrandList.length > 0)) {
  489. flag = false
  490. } else {
  491. flag = true
  492. }
  493. }
  494. })
  495. return flag
  496. },
  497. // 重置表格
  498. resetSearchForm () {
  499. this.form = {
  500. giveRuleType: 'RATIO', // 满赠规则类型: SUM_MONEY[金额叠加] / RATIO[按比例] 满产品送产品写死为: 按比例
  501. promotionRuleType: 'BUY_PROD_GIVE_PROD', // 买产品送产品
  502. description: '', // 简称
  503. gateFlag: '0', // 门槛
  504. gateType: undefined,
  505. gateValue: undefined,
  506. quotaAmount: undefined,
  507. regularSameFlag: '1', // 满赠规则 同款不同款商品
  508. regularUnit: 'GE',
  509. restrictFlag: '0', // 限制正价产品款数
  510. convertExpenseFlag: '0', // 转费用报销标记
  511. restrictCategory: '',
  512. accrualFlag: '1', // 数量叠加
  513. regularPromotionSameFlag: '1',
  514. giftProductMap: {},
  515. gateProductList: undefined,
  516. regularProductList: undefined,
  517. gateInfo: undefined,
  518. ruleInfo: undefined
  519. }
  520. this.$nextTick(() => {
  521. this.$refs.ruleForm.resetFields()
  522. this.$refs.cillProduct.reSetTableData()
  523. this.$refs.normalPriceProduct.reSetTableData()
  524. })
  525. this.fullGiftRuleList.forEach((val, i) => {
  526. this.$refs['offerProduct' + i][0].reSetTableData()
  527. })
  528. this.fullGiftRuleList = [{
  529. id: this.generateRandomString(),
  530. regularValue: undefined,
  531. promotionValue: undefined
  532. }]
  533. this.id = ''
  534. },
  535. // 获取编辑详情
  536. getDetail () {
  537. const _this = this
  538. getRuleDetail({ sn: _this.itemSn }).then(res => {
  539. if (res.status == 200) {
  540. const resultObj = res.data
  541. _this.chooseVal = resultObj.gateFlag == '0' ? 'b' : 'a'
  542. if (resultObj.gateFlag == '1') {
  543. resultObj.gateValue = resultObj.gateType === 'RATIO_AMOUNT' ? resultObj.gateValue * 100 : resultObj.gateValue
  544. }
  545. if (resultObj.giveRuleList && resultObj.giveRuleList.length > 0) {
  546. _this.fullGiftRuleList = resultObj.giveRuleList
  547. _this.$nextTick(() => {
  548. resultObj.giveRuleList.forEach((item, i) => {
  549. _this.$refs['offerProduct' + i][0].setTabVal(_this.newData(resultObj.giftProductMap['GIFT' + (i * 1 + 1)]))
  550. })
  551. })
  552. }
  553. // 重新组成保存数据
  554. if (resultObj.gateProductList && resultObj.gateProductList.length > 0) {
  555. resultObj.gateProductList = _this.newData(resultObj.gateProductList)
  556. _this.$refs.cillProduct.setTabVal(resultObj.gateProductList)
  557. }
  558. if (resultObj.regularProductList && resultObj.regularProductList.length > 0) {
  559. resultObj.regularProductList = _this.newData(resultObj.regularProductList)
  560. _this.$refs.normalPriceProduct.setTabVal(resultObj.regularProductList)
  561. }
  562. _this.form = { ..._this.form, ...resultObj }
  563. }
  564. })
  565. },
  566. newData (list) {
  567. list.forEach(con => {
  568. // 品牌
  569. if (con.productBrandList) {
  570. const brandList = []
  571. con.productBrandList.forEach(item => {
  572. item.brandName = item.productBrandName
  573. const brandObj = {
  574. productBrandSn: item.productBrandSn
  575. }
  576. brandList.push(brandObj)
  577. })
  578. con.productBrandArr = con.productBrandList
  579. con.productBrandList = brandList
  580. }
  581. // 分类
  582. if (con.productTypeList) {
  583. const typeList = []
  584. con.productTypeList.forEach(item => {
  585. const typeObj = {}
  586. const num = 3
  587. for (var i = 0; i < num; i++) {
  588. if (item['productTypeName' + (i + 1)]) {
  589. typeObj['productTypeSn' + (i + 1)] = item['productTypeSn' + (i + 1)] ? item['productTypeSn' + (i + 1)] : ''
  590. }
  591. }
  592. if (item.productTypeName3) {
  593. item.title = item.productTypeName2 + '/' + item.productTypeName3
  594. } else if (!item.productTypeName3 && item.productTypeName2) {
  595. item.title = item.productTypeName2
  596. } else {
  597. item.title = item.productTypeName1
  598. }
  599. item.id = item.productTypeSn3 ? item.productTypeSn3 : item.productTypeSn2 ? item.productTypeSn2 : item.productTypeSn1
  600. typeList.push(typeObj)
  601. })
  602. con.productTypeArr = con.productTypeList
  603. con.productTypeList = typeList
  604. }
  605. // 产品
  606. if (con.productThisList) {
  607. const productList = []
  608. con.productThisList.forEach(item => {
  609. const productObj = {
  610. productCode: item.productCode,
  611. productSn: item.productSn
  612. }
  613. productList.push(productObj)
  614. })
  615. con.productThisList = productList
  616. }
  617. })
  618. return list
  619. }
  620. },
  621. watch: {
  622. // 父页面传过来的弹框状态
  623. openModal (newValue, oldValue) {
  624. this.isShow = newValue
  625. },
  626. // 重定义的弹框状态
  627. isShow (newValue, oldValue) {
  628. if (!newValue) {
  629. this.$emit('close')
  630. this.resetSearchForm()
  631. } else {
  632. if (this.itemSn) {
  633. this.getDetail()
  634. } else {
  635. this.chooseVal = this.form.gateFlag == '0' ? 'b' : 'a'
  636. }
  637. }
  638. }
  639. }
  640. }
  641. </script>
  642. <style lang="less" scoped>
  643. .promotionList-basicInfo-modal{
  644. /deep/.ant-modal-body {
  645. padding: 20px 30px;
  646. max-height: 745px !important;
  647. overflow-y: scroll !important;
  648. }
  649. .fixWidthBox .ant-radio-button-wrapper{
  650. width:80px;
  651. text-align: center;
  652. }
  653. .ant-form-item{
  654. margin-bottom:5px;
  655. }
  656. .buyerBox{
  657. border:1px solid #d9d9d9;margin-top:10px;border-radius:4px;padding:4px 10px;background:#f2f2f2;max-height:130px;overflow-y:scroll;
  658. }
  659. .btn-cont {
  660. text-align: center;
  661. margin: 35px 0 10px;
  662. }
  663. .flex{
  664. display:flex;
  665. align-items:center;
  666. justify-content:space-between;
  667. }
  668. .ant-radio-button-wrapper-disabled.ant-radio-button-wrapper-checked{
  669. background-color: #ed1c24 !important;
  670. }
  671. }
  672. </style>