specialOfferModal.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  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="83%">
  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="gateFlag">
  20. <a-radio-group v-model="form.gateFlag" button-style="solid" size="small" @change="handleChange">
  21. <a-radio-button value="1">
  22. </a-radio-button>
  23. <a-radio-button value="0">
  24. </a-radio-button>
  25. </a-radio-group>
  26. <div v-if="form.gateFlag && form.gateFlag === '1'">
  27. <v-select
  28. size="small"
  29. style="width:60%;"
  30. v-model="form.gateType"
  31. id="promotionList-gateType"
  32. code="PROMOTION_GATE_TYPE"
  33. placeholder="请选择门槛与配额设置要求"
  34. @change="changeGateTypeFlag"
  35. allowClear></v-select>
  36. <div v-if="form.gateType==='RATIO_AMOUNT'">
  37. 购买门槛产品金额 <a-input-number v-model="form.gateValue" :min="0" :max="999999" :precision="2" size="small"/> %作为配额
  38. <a-tooltip title="如:填写100%,则购买10000元门槛产品,可享受10000配额购买特价产品,根据门槛金额动态调整配额">
  39. <a-icon type="question-circle" theme="filled" :style="{ fontSize: '14px', color: 'gray' }"/>
  40. </a-tooltip>
  41. </div>
  42. <div v-if="form.gateType==='MIN_AMOUNT'">
  43. 购买门槛产品满最低金额 <a-input-number v-model="form.gateValue" :min="0" :max="999999" :precision="2" size="small"/>元,不限制配额。
  44. </div>
  45. <div class="ruleDescList" v-if="form.gateType==='FIXED_AMOUNT'">
  46. 购买每满
  47. <a-input-number v-model="form.gateValue" :max="999999" :min="0" :precision="2" size="small"/>
  48. <a-select default-value="YUAN" v-model="form.regularUnit" style="width: 50px;margin-left:5px;" size="small" allowClear>
  49. <a-select-option value="YUAN">
  50. </a-select-option>
  51. <a-select-option value="GE">
  52. </a-select-option>
  53. </a-select>
  54. 门槛产品,可采购
  55. <a-input-number v-model="form.quotaAmount" :max="999999" :min="0" :precision="2" size="small"/>
  56. 个特价产品(配额算销售额)
  57. </div>
  58. </div>
  59. </a-form-model-item>
  60. <a-form-model-item label="规则简称" prop="description">
  61. <a-input
  62. size="small"
  63. id="promotionList-description"
  64. v-model.trim="form.description"
  65. allowClear
  66. placeholder="请输入规则简称(最多20个字符)"
  67. :maxLength="20"></a-input>
  68. </a-form-model-item>
  69. <a-form-model-item label="特价规则" prop="discountType">
  70. <a-select
  71. default-value="0"
  72. v-model="form.discountType"
  73. placeholder="请选择"
  74. style="width:60%;"
  75. size="small"
  76. @change="handleDiscountType"
  77. allowClear>
  78. <a-select-option value="0">
  79. 手动输入特价
  80. </a-select-option>
  81. <a-select-option value="1">
  82. 各级别价打折
  83. </a-select-option>
  84. <a-select-option value="2">
  85. 各级别价直降
  86. </a-select-option>
  87. </a-select>
  88. <a-table
  89. v-show="form.discountType!=0"
  90. class="sTable"
  91. ref="setTable"
  92. size="small"
  93. :rowKey="(record) => record.id"
  94. :columns="setColumns"
  95. :dataSource="setTableData"
  96. :pagination="false"
  97. style="width:60%;"
  98. bordered>
  99. <template slot="provinceDiscount" slot-scope="text, record">
  100. <a-input-number
  101. size="small"
  102. v-model="record.provinceValue"
  103. :min="0"
  104. :step="1"
  105. :precision="2"
  106. :max="999999"
  107. placeholder="请输入"/>%
  108. </template>
  109. <template slot="cityDiscount" slot-scope="text, record">
  110. <a-input-number
  111. size="small"
  112. v-model="record.cityValue"
  113. :min="record.provinceValue||0"
  114. :step="1"
  115. :precision="2"
  116. :max="999999"
  117. placeholder="请输入"/>%
  118. </template>
  119. <template slot="specialDiscount" slot-scope="text, record">
  120. <a-input-number
  121. size="small"
  122. v-model="record.specialValue"
  123. :min="record.cityValue ||0"
  124. :step="1"
  125. :precision="2"
  126. :max="999999"
  127. placeholder="请输入"/>%
  128. </template>
  129. <template slot="provincePrice" slot-scope="text, record">
  130. <a-input-number
  131. size="small"
  132. v-model="record.provinceValue"
  133. :min="0"
  134. :step="1"
  135. :precision="2"
  136. :max="999999"
  137. placeholder="请输入"/>
  138. </template>
  139. <template slot="cityPrice" slot-scope="text, record">
  140. <a-input-number
  141. size="small"
  142. v-model="record.cityValue"
  143. :min="0"
  144. :step="1"
  145. :precision="2"
  146. :max="record.provinceValue||999999"
  147. placeholder="请输入"/>
  148. </template>
  149. <template slot="specialPrice" slot-scope="text, record">
  150. <a-input-number
  151. size="small"
  152. v-model="record.specialValue"
  153. :min="0"
  154. :step="1"
  155. :precision="2"
  156. :max="record.cityValue||999999"
  157. placeholder="请输入"/>
  158. </template>
  159. </a-table>
  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="d">
  169. 特价产品
  170. </a-radio-button>
  171. </a-radio-group>
  172. <div>
  173. <a-button
  174. size="small"
  175. type="link"
  176. class="button-info"
  177. id="promotionList-edit-btn"
  178. @click="openGuideModal=true"
  179. >+导入产品</a-button>
  180. <a-button
  181. v-show="chooseVal==='d'"
  182. style="margin-left:10px;"
  183. size="small"
  184. type="link"
  185. class="button-error"
  186. id="promotionList-edit-btn"
  187. @click="addProducts">+新增产品</a-button>
  188. </div>
  189. </div>
  190. <div v-show="chooseVal=='a'"><tableType1 ref="cillProduct"></tableType1></div>
  191. <div v-show="chooseVal=='d'"><tableType3 :setData="setTableData" :rulesType="form.discountType" ref="specialProduct"></tableType3></div>
  192. </a-card>
  193. <div class="btn-cont">
  194. <a-button id="promotionList-basicInfo-modal-back" @click="isShow = false">取消</a-button>
  195. <a-button style="margin-left: 15px;" type="primary" id="promotionList-modal-save" @click="handleSave">确定</a-button>
  196. </div>
  197. </a-spin>
  198. <!-- 选择产品 -->
  199. <chooseProductsModal
  200. type="dealership"
  201. ref="productBox"
  202. :openModal="openProductsModal"
  203. :chooseData="chooseProducts"
  204. @close="openProductsModal=false"
  205. @ok="handleProductsAdd" />
  206. <!-- 导入产品 -->
  207. <importGuideModal :goodFlag="chooseVal=='a'?'1':'0'" :discountType="form.discountType" :openModal="openGuideModal" @close="closeGuideModel" @ok="hanldeOk" />
  208. </a-modal>
  209. </template>
  210. <script>
  211. import { commonMixin } from '@/utils/mixin'
  212. import { VSelect } from '@/components'
  213. import tableType1 from './tableType1.vue'
  214. import tableType3 from './tableType3.vue'
  215. import { promotionSave, getRuleDetail, getNewScopeSn } from '@/api/promotion'
  216. import chooseProductsModal from './chooseProductsModal.vue'
  217. import ImportGuideModal from './importGuideModal.vue'
  218. export default {
  219. name: 'PromotionListBasicInfoModal',
  220. mixins: [commonMixin],
  221. components: { VSelect, tableType1, tableType3, chooseProductsModal, ImportGuideModal },
  222. props: {
  223. openModal: { // 弹框显示状态
  224. type: Boolean,
  225. default: false
  226. },
  227. promotionSn: {
  228. type: [Number, String],
  229. default: ''
  230. },
  231. itemSn: {
  232. type: [Number, String],
  233. default: ''
  234. }
  235. },
  236. data () {
  237. return {
  238. isShow: this.openModal, // 是否打开弹框
  239. spinning: false,
  240. formItemLayout: {
  241. labelCol: { span: 4 },
  242. wrapperCol: { span: 17 }
  243. },
  244. form: {
  245. promotionRuleType: 'PROMO_PROD', // 特价产品
  246. description: '', // 规则简称
  247. gateFlag: '0', // 门槛
  248. gateType: undefined,
  249. gateValue: undefined,
  250. regularUnit: 'YUAN',
  251. quotaAmount: undefined,
  252. discountType: '0'// 特价规则
  253. },
  254. rules: {
  255. description: [ { required: true, message: '请输入规则简称', trigger: 'blur' } ],
  256. gateFlag: [ { required: true, message: '请选择规则门槛', trigger: 'change' } ],
  257. discountType: [{ required: true, message: '请选择特价规则', trigger: 'change' }]
  258. },
  259. setTableData: [{
  260. provinceValue: undefined,
  261. cityValue: undefined,
  262. specialValue: undefined
  263. }],
  264. chooseVal: 'a',
  265. openProductsModal: false,
  266. chooseProducts: [],
  267. openGuideModal: false // 导入弹窗
  268. }
  269. },
  270. computed: {
  271. setColumns () {
  272. const _this = this
  273. var arr = []
  274. if (_this.form.discountType === '1') {
  275. arr = [
  276. { title: '省价折扣', scopedSlots: { customRender: 'provinceDiscount' }, width: '33%', align: 'center' },
  277. { title: '市价折扣', scopedSlots: { customRender: 'cityDiscount' }, width: '33%', align: 'center' },
  278. { title: '特约折扣', scopedSlots: { customRender: 'specialDiscount' }, width: '33%', align: 'center' }
  279. ]
  280. } else if (_this.form.discountType === '2') {
  281. arr = [
  282. { title: '省价直降', scopedSlots: { customRender: 'provincePrice' }, width: '33%', align: 'center' },
  283. { title: '市价直降', scopedSlots: { customRender: 'cityPrice' }, width: '33%', align: 'center' },
  284. { title: '特约直降', scopedSlots: { customRender: 'specialPrice' }, width: '33%', align: 'center' }
  285. ]
  286. }
  287. return arr
  288. }
  289. },
  290. methods: {
  291. // 特价规则切换时清空数据
  292. handleDiscountType (val) {
  293. this.form.discountType = val
  294. this.$refs.specialProduct.reSetTableData()
  295. },
  296. // 导入
  297. closeGuideModel () {
  298. this.openGuideModal = false
  299. },
  300. // 门槛产品
  301. handleChange (e) {
  302. if (e.target.value == '1') {
  303. this.chooseVal = 'a'
  304. } else {
  305. this.chooseVal = 'd'
  306. this.form.gateType = undefined
  307. this.form.gateValue = undefined
  308. this.form.quotaAmount = undefined
  309. }
  310. },
  311. changeGateTypeFlag (val) {
  312. this.form.gateType = val
  313. this.form.gateValue = undefined
  314. this.form.quotaAmount = undefined
  315. },
  316. // 保存
  317. handleSave () {
  318. const _this = this
  319. this.$refs.ruleForm.validate(valid => {
  320. if (valid) {
  321. // 验证必填
  322. if (_this.form.gateFlag === '1') {
  323. if (!_this.form.gateType) {
  324. _this.$message.warning('请选择规则门槛设置类型!')
  325. return
  326. }
  327. if (!_this.form.gateValue) {
  328. _this.$message.warning('规则门槛条件不能为空!')
  329. return
  330. }
  331. if (_this.form.gateType === 'FIXED_AMOUNT' && !_this.form.quotaAmount) {
  332. _this.$message.warning('规则门槛条件不能为空!')
  333. return
  334. }
  335. }
  336. const form = JSON.parse(JSON.stringify(_this.form))
  337. if (form.gateFlag === '1') {
  338. form.gateProductList = _this.$refs.cillProduct.getResultVal()
  339. form.gateValue = form.gateType === 'RATIO_AMOUNT' ? form.gateValue / 100 : form.gateValue
  340. if (form.gateProductList.length == 0) {
  341. _this.$message.warning('请添加门槛产品!')
  342. return
  343. } else {
  344. const qtyFlag = form.gateProductList.some(newCon => { return (!newCon.unitType || !newCon.unitQty) })
  345. if (qtyFlag) {
  346. _this.$message.warning('订单起订量设置不能为空!')
  347. return
  348. }
  349. const rowFlag = _this.isJudge(form.gateProductList)
  350. if (rowFlag) {
  351. _this.$message.warning('请选择产品分类、品牌或产品!')
  352. return
  353. }
  354. }
  355. } else {
  356. form.gateProductList = []
  357. form.gateValue = ''
  358. form.quotaAmount = ''
  359. form.gateType = undefined
  360. }
  361. form.specialProductList = _this.$refs.specialProduct.getResultVal()
  362. // 为空判断
  363. const isTypeEmpty = form.specialProductList.some(item => (item.productTypeList && item.productTypeList.length == 0) && (item.productBrandList && item.productBrandList.length == 0))
  364. if (isTypeEmpty) {
  365. _this.$message.warning('产品分类或品牌不能为空!')
  366. return
  367. }
  368. const isNumEmpty = form.specialProductList.some(item => (!item.unitType || !item.unitQty))
  369. if (isNumEmpty) {
  370. _this.$message.warning('订单起订量设置不能为空!')
  371. return
  372. }
  373. if (form.discountType === '0') { // 手动输入
  374. const isCountEmpty = _this.isNumEmpty(form.specialProductList)
  375. if (isCountEmpty.flag) {
  376. _this.$message.warning('折扣不能为空!')
  377. return
  378. }
  379. if (isCountEmpty.flag1) {
  380. _this.$message.warning('折扣金额不能为空!')
  381. return
  382. }
  383. } else {
  384. if (form.discountType === '2') { // 直降价格为负判断
  385. const hasNegativePrice = form.specialProductList.some((item) => (item.provinceDiscountPrice < 0 || item.cityDiscountPrice < 0 || item.specialDiscountPrice < 0))
  386. if (hasNegativePrice) {
  387. _this.$message.warning('直降后价格不能为负值!')
  388. return
  389. }
  390. }
  391. form.provinceValue = _this.setTableData[0].provinceValue
  392. form.cityValue = _this.setTableData[0].cityValue
  393. form.specialValue = _this.setTableData[0].specialValue
  394. }
  395. form.promotionSn = _this.promotionSn
  396. _this.spinning = true
  397. promotionSave(form).then(res => {
  398. if (res.status == 200) {
  399. _this.$message.success(res.message)
  400. setTimeout(() => {
  401. _this.isShow = false
  402. _this.$emit('ok')
  403. _this.spinning = false
  404. }, 1000)
  405. } else {
  406. _this.spinning = false
  407. }
  408. })
  409. } else {
  410. return false
  411. }
  412. })
  413. },
  414. isNumEmpty (dataList) {
  415. const arr = []
  416. const arr1 = []
  417. dataList.forEach(item => {
  418. if (item.dataSourceOrigin === '0') { // 判断分类品牌
  419. if (!item.provinceDiscountRate || !item.cityDiscountRate || !item.specialDiscountRate) {
  420. arr.push(item.productScopeSn)
  421. }
  422. } else {
  423. if (!item.cityDiscountPrice || !item.provinceDiscountPrice || !item.specialDiscountPrice) {
  424. arr1.push(item.productScopeSn)
  425. }
  426. }
  427. })
  428. return { flag: arr.length > 0, flag1: arr1.length > 0 }
  429. },
  430. // 判断门槛产品中品牌,分类,产品其中一个必填
  431. isJudge (list) {
  432. const flag = list.some(con => {
  433. if (con.productThisList) {
  434. if (con.productThisList.length > 0) {
  435. return false
  436. } else {
  437. if ((con.productTypeList && con.productTypeList.length > 0) || (con.productBrandList && con.productBrandList.length > 0)) {
  438. return false
  439. } else {
  440. return true
  441. }
  442. }
  443. } else {
  444. if ((con.productTypeList && con.productTypeList.length > 0) || (con.productBrandList && con.productBrandList.length > 0)) {
  445. return false
  446. } else {
  447. return true
  448. }
  449. }
  450. })
  451. return flag
  452. },
  453. // 重置表格
  454. resetSearchForm () {
  455. this.form = {
  456. promotionRuleType: 'PROMO_PROD', // 特价产品
  457. description: '', // 规则简称
  458. gateFlag: '0', // 门槛
  459. gateType: undefined,
  460. gateValue: undefined,
  461. regularUnit: 'YUAN',
  462. quotaAmount: undefined,
  463. discountType: '0', // 特价规则
  464. gateProductList: undefined,
  465. specialProductList: undefined
  466. }
  467. this.$nextTick(() => {
  468. this.$refs.ruleForm.resetFields()
  469. this.$refs.cillProduct.reSetTableData()
  470. this.$refs.specialProduct.reSetTableData()
  471. })
  472. if (this.form.discountType != '0') {
  473. this.$refs[0].setTable.clearTable()
  474. }
  475. this.setTableData = []
  476. },
  477. // 获取编辑详情
  478. getDetail () {
  479. const _this = this
  480. getRuleDetail({ sn: this.itemSn }).then(res => {
  481. if (res.status == 200) {
  482. this.chooseVal = res.data.gateFlag == '0' ? 'd' : 'a'
  483. const resultObj = res.data
  484. if (resultObj.gateFlag === '1') {
  485. resultObj.gateValue = resultObj.gateType === 'RATIO_AMOUNT' ? resultObj.gateValue * 100 : resultObj.gateValue
  486. }
  487. if (resultObj.discountType != '0') {
  488. _this.setTableData = [{
  489. provinceValue: resultObj.provinceValue,
  490. cityValue: resultObj.cityValue,
  491. specialValue: resultObj.specialValue
  492. }]
  493. }
  494. // 重新组成保存数据
  495. if (resultObj.gateProductList && resultObj.gateProductList.length > 0) {
  496. resultObj.gateProductList = _this.newData(resultObj.gateProductList)
  497. this.$refs.cillProduct.setTabVal(resultObj.gateProductList)
  498. }
  499. if (resultObj.specialProductList && resultObj.specialProductList.length > 0) {
  500. resultObj.specialProductList = _this.newData(resultObj.specialProductList)
  501. this.$refs.specialProduct.setSourceData(resultObj.specialProductList)
  502. }
  503. this.form = { ...this.form, ...resultObj }
  504. }
  505. })
  506. },
  507. newData (list) {
  508. list.forEach(con => {
  509. // 品牌
  510. if (con.productBrandList) {
  511. const brandList = []
  512. con.productBrandList.forEach(item => {
  513. item.brandName = item.productBrandName
  514. const brandObj = {
  515. productBrandSn: item.productBrandSn
  516. }
  517. brandList.push(brandObj)
  518. })
  519. con.productBrandArr = con.productBrandList
  520. con.productBrandList = brandList
  521. }
  522. // 分类
  523. if (con.productTypeList) {
  524. const typeList = []
  525. con.productTypeList.forEach(item => {
  526. const typeObj = {}
  527. item.title = ''
  528. const num = 3
  529. for (var i = 0; i < num; i++) {
  530. if (item['productTypeName' + (i + 1)]) {
  531. // item.title += item['productTypeName' + (i + 1)] + (item['productTypeName' + (i + 1)] ? '/' : '')
  532. typeObj['productTypeSn' + (i + 1)] = item['productTypeSn' + (i + 1)] ? item['productTypeSn' + (i + 1)] : ''
  533. }
  534. }
  535. // item.title = item.title.slice(0, item.title.length - 1)
  536. if (item.productTypeName3) {
  537. item.title = item.productTypeName2 + '/' + item.productTypeName3
  538. } else if (!item.productTypeName3 && item.productTypeName2) {
  539. item.title = item.productTypeName2
  540. } else {
  541. item.title = item.productTypeName1
  542. }
  543. item.id = item.productTypeSn3 ? item.productTypeSn3 : item.productTypeSn2 ? item.productTypeSn2 : item.productTypeSn1
  544. typeList.push(typeObj)
  545. })
  546. con.productTypeArr = con.productTypeList
  547. con.productTypeList = typeList
  548. }
  549. // 产品
  550. if (con.productThisList) {
  551. const productList = []
  552. con.productThisList.forEach(item => {
  553. const productObj = {
  554. productCode: item.productCode,
  555. productSn: item.productSn
  556. }
  557. productList.push(productObj)
  558. })
  559. con.productThisList = productList
  560. }
  561. })
  562. return list
  563. },
  564. // 导入
  565. hanldeOk (arr) {
  566. // 门槛产品导入
  567. const resultArr = []
  568. if (this.chooseVal == 'a') {
  569. const name = this.chooseVal == 'a' ? 'cill' : this.chooseVal == 'b' ? 'normalPrice' : 'offer'
  570. this.$refs[name + 'Product'].importRow(arr)
  571. } else {
  572. // 特价产品导入
  573. const dataList = this.setShowData('This')
  574. arr.forEach(item => {
  575. item = { ...item, ...item.product }
  576. item.code = item.productCode
  577. if (item.provincePrice) {
  578. item.provinceDiscountRate = Math.floor(((item.provinceDiscountPriceText / item.provincePrice) * 100).toFixed(2))
  579. }
  580. if (item.cityPrice) {
  581. item.cityDiscountRate = Math.floor(((item.cityDiscountPriceText / item.cityPrice) * 100).toFixed(2))
  582. }
  583. if (item.specialPrice) {
  584. item.specialDiscountRate = Math.floor(((item.specialDiscountPriceText / item.specialPrice) * 100).toFixed(2))
  585. }
  586. const flag = dataList.includes(item.productSn)
  587. if (!flag) {
  588. resultArr.push(item)
  589. }
  590. })
  591. if (resultArr.length > 0) {
  592. this.handleProductsOk(resultArr)
  593. } else {
  594. this.$message.warning('请勿添加重复数据!')
  595. }
  596. }
  597. },
  598. // 打开新增产品弹窗(禁用已选)
  599. addProducts () {
  600. this.chooseProducts = []
  601. this.openProductsModal = true
  602. const dataList = this.setShowData('This')
  603. this.$refs.productBox.handleDisabled(dataList)
  604. },
  605. // 获取回显禁用数据
  606. setShowData (name) {
  607. const _this = this
  608. const snArr = []
  609. const valList = _this.$refs.specialProduct.getResultVal()
  610. valList.forEach(item => {
  611. if (item['product' + name + 'List'] && item['product' + name + 'List'].length > 0) {
  612. item['product' + name + 'List'].forEach(con => {
  613. const newName = name === 'This' ? '' : name
  614. snArr.push(con['product' + newName + 'Sn'])
  615. })
  616. }
  617. })
  618. return snArr
  619. },
  620. handleProductsAdd (con) {
  621. const newArr = []
  622. const newConArr = []
  623. con.forEach(newCon => {
  624. if (!newCon.provincePrice || !newCon.cityPrice || !newCon.specialPrice) {
  625. newArr.push(newCon.code)
  626. }
  627. })
  628. con.forEach((list, pos) => {
  629. if (list.provincePrice && list.cityPrice && list.specialPrice) {
  630. newConArr.push(list)
  631. }
  632. })
  633. const _this = this
  634. if (newArr && newArr.length > 0) {
  635. _this.$info({
  636. title: '提示',
  637. content: newArr.toString() + '(产品编码),没有定价,不可添加',
  638. closable: true,
  639. centered: true,
  640. onOk () {
  641. _this.handleProductsOk(newConArr)
  642. }
  643. })
  644. } else {
  645. _this.handleProductsOk(newConArr)
  646. }
  647. },
  648. // +新增产品
  649. handleProductsOk (con) {
  650. const _this = this
  651. con.forEach(async (item) => {
  652. const chooseProductsList = []
  653. const getSn = await getNewScopeSn({})
  654. if (getSn.status == 200) {
  655. const newData = {
  656. productScopeSn: getSn.data,
  657. dataSourceOrigin: '1',
  658. productTypeArr: [],
  659. productTypeList: [],
  660. productBrandArr: [{ productBrandSn: item.productBrandSn, brandName: item.productBrandName }],
  661. productBrandList: [{ productBrandSn: item.productBrandSn }],
  662. productThisList: [{
  663. productSn: item.productSn,
  664. productCode: item.code
  665. }],
  666. provincePrice: item.provincePrice,
  667. cityPrice: item.cityPrice,
  668. specialPrice: item.specialPrice,
  669. provinceDiscountPrice: item.provinceDiscountPriceText,
  670. cityDiscountPrice: item.cityDiscountPriceText,
  671. specialDiscountPrice: item.specialDiscountPriceText,
  672. unitType: item.unitType || 'SL',
  673. unitQty: item.unitQty || '1',
  674. provinceDiscountRate: item.provinceDiscountRate ? item.provinceDiscountRate : undefined,
  675. cityDiscountRate: item.cityDiscountRate ? item.cityDiscountRate : undefined,
  676. specialDiscountRate: item.specialDiscountRate ? item.specialDiscountRate : undefined
  677. }
  678. const obj = {}
  679. if (item.productTypeSn1) {
  680. obj.productTypeSn1 = item.productTypeSn1
  681. }
  682. if (item.productTypeSn2) {
  683. obj.productTypeSn2 = item.productTypeSn2
  684. }
  685. if (item.productTypeSn3) {
  686. obj.productTypeSn3 = item.productTypeSn3
  687. }
  688. const newObj = { ...obj, ...{} }
  689. if (Object.keys(obj).length == 1) {
  690. newObj.title = item.productTypeName1
  691. newObj.id = item.productTypeSn1
  692. } else if (Object.keys(obj).length == 2) {
  693. newObj.title = item.productTypeName2
  694. newObj.id = item.productTypeSn2
  695. } else {
  696. newObj.title = item.productTypeName2 + '/' + item.productTypeName3
  697. newObj.id = item.productTypeSn3
  698. }
  699. newData.productTypeList[0] = obj
  700. newData.productTypeArr[0] = newObj
  701. chooseProductsList.push(newData)
  702. }
  703. _this.$refs.specialProduct.setSourceData(chooseProductsList)
  704. })
  705. }
  706. },
  707. watch: {
  708. // 父页面传过来的弹框状态
  709. openModal (newValue, oldValue) {
  710. this.isShow = newValue
  711. },
  712. // 重定义的弹框状态
  713. isShow (newValue, oldValue) {
  714. if (!newValue) {
  715. this.$emit('close')
  716. this.resetSearchForm()
  717. } else {
  718. if (this.itemSn) {
  719. this.getDetail()
  720. } else {
  721. this.chooseVal = this.form.gateFlag == '0' ? 'd' : 'a'
  722. }
  723. }
  724. }
  725. }
  726. }
  727. </script>
  728. <style lang="less" scoped>
  729. .promotionList-basicInfo-modal{
  730. /deep/.ant-modal-body {
  731. padding: 20px 30px;
  732. max-height: 745px !important;
  733. overflow-y: scroll !important;
  734. }
  735. .ant-radio-button-wrapper{
  736. width:80px;
  737. text-align: center;
  738. }
  739. .ant-form-item{
  740. margin-bottom:5px;
  741. }
  742. .buyerBox{
  743. border:1px solid #d9d9d9;margin-top:10px;border-radius:4px;padding:4px 10px;background:#f2f2f2;max-height:130px;overflow-y:scroll;
  744. }
  745. .btn-cont {
  746. text-align: center;
  747. margin: 35px 0 10px;
  748. }
  749. .flex{
  750. display:flex;
  751. align-items:center;
  752. justify-content:space-between;
  753. }
  754. }
  755. </style>