sendAmountModal.vue 25 KB

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