sendAmountModal.vue 26 KB

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