edit.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. <template>
  2. <div class="salesNewEdit-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" @back="handleBack" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="salesEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <span style="margin: 0 15px;color: #666;font-weight: bold;">单号:{{ detailData&&detailData.salesBillNo }}</span>
  9. <span v-if="detailData&&detailData.salesBillNoSource">(原:{{ detailData&&detailData.salesBillNoSource || '--' }})</span>
  10. <span style="margin: 0 10px;color: #666;">客户名称:{{ detailData&&detailData.buyerName }}</span>
  11. <a-button type="link" size="small" class="button-default" @click="showDetail=!showDetail">
  12. <a-icon :type="showDetail ? 'eye-invisible' : 'eye'"/> {{ showDetail?'隐藏':'查看' }}信息
  13. </a-button>
  14. </template>
  15. </a-page-header>
  16. <!-- 单据详情 -->
  17. <a-card size="small" :bordered="false" class="salesEdit-cont" v-show="showDetail">
  18. <div style="padding: 10px;">
  19. <a-descriptions size="small" :column="3">
  20. <a-descriptions-item label="客户名称">{{ detailData&&detailData.buyerName || '--' }}</a-descriptions-item>
  21. <a-descriptions-item label="收货地址" :span="2">{{ shippingAddress||'--' }}</a-descriptions-item>
  22. <a-descriptions-item label="收货人">{{ detailData&&detailData.salesBillExtEntity&&detailData.salesBillExtEntity.consigneeName || '--' }}</a-descriptions-item>
  23. <a-descriptions-item label="收货电话">{{ detailData&&detailData.salesBillExtEntity&&detailData.salesBillExtEntity.consigneeTel || '--' }}</a-descriptions-item>
  24. <a-descriptions-item label="收款方式">{{ detailData&&detailData.settleStyleSnDictValue || '--' }}</a-descriptions-item>
  25. <a-descriptions-item label="审核时间">{{ detailData&&detailData.auditDate || '--' }}</a-descriptions-item>
  26. <a-descriptions-item label="业务状态">{{ detailData&&detailData.billStatusDictValue || '--' }}</a-descriptions-item>
  27. <a-descriptions-item label="财务状态">{{ detailData&&detailData.financialStatusDictValue || '--' }}</a-descriptions-item>
  28. <a-descriptions-item label="改单时间" v-if="detailData&&detailData.salesBillSource=='PURCHASE'&&detailData.submitDate">{{ detailData.submitDate }}</a-descriptions-item>
  29. <a-descriptions-item label="最新提交时间" v-if="detailData&&detailData.salesBillSource=='SALES'&&detailData.submitDate">{{ detailData.submitDate }}</a-descriptions-item>
  30. <a-descriptions-item label="备注" :span="3">{{ detailData&&detailData.remarks || '--' }}</a-descriptions-item>
  31. </a-descriptions>
  32. </div>
  33. </a-card>
  34. <!-- 正常产品 -->
  35. <a-card size="small" :bordered="false" class="salesEdit-cont" v-if="salesBillSn">
  36. <div style="padding: 10px;">
  37. <productNormalList
  38. ref="productNormalList"
  39. @insterOk="insterActiveOk"
  40. @openCpModal="openProductModal"
  41. :showTotal="showTotal"
  42. :detailData="detailData"
  43. :warehouseSn="warehouseSn"
  44. :salesBillSn="salesBillSn"></productNormalList>
  45. </div>
  46. </a-card>
  47. <!-- 活动产品 -->
  48. <a-card
  49. size="small"
  50. :bordered="false"
  51. class="salesEdit-cont"
  52. v-for="item in activeList"
  53. :key="item.promoRuleSn"
  54. v-if="activeList.length"
  55. >
  56. <div slot="title" style="display: inline-block;width:100%;">
  57. <strong style="margin-right:10px;font-size:14px;">{{ item.promotion.description }}</strong> ({{ item.promotionRule.description }})
  58. <span style="margin-left:20px;color:#00aaff;cursor: pointer;" @click="(event) => {showDesc(event, item)}">
  59. <a-icon :type="item.showDesc ? 'eye-invisible' : 'eye'"/> 活动详情
  60. </span>
  61. <span :style="{margin:'0 20px',color:item.disabled?'#14b900':'#ff0800',cursor: 'pointer'}" @click="(event) => {disenablePromp(event, item)}">
  62. <a-icon title="禁用规则" :type="item.disabled?'link':'disconnect'"/> {{ item.disabled ? '启用规则' : '禁用规则' }}
  63. </span>
  64. </div>
  65. <div slot="extra" @click="tooglePanel(item)" style="cursor: pointer;">{{ item.isActive ? '收起' : '展开' }} <a-icon type="caret-right" :rotate="item.isActive ? 90 : 0"/> </div>
  66. <div v-show="item.isActive" style="padding: 10px;">
  67. <productList
  68. :ref="'productList-'+item.promoRuleSn"
  69. :id="item.promoRuleSn"
  70. @openCpModal="openProductModal"
  71. @insterOk="insterActiveOk"
  72. @showDesc="v => showDescOk(v,item)"
  73. @upActive="upActive"
  74. :promo="item"
  75. :detailData="detailData"
  76. :warehouseSn="warehouseSn"
  77. :salesBillSn="salesBillSn"></productList>
  78. </div>
  79. </a-card>
  80. </a-spin>
  81. <div class="affix-cont">
  82. <div class="footer-price">
  83. <div></div>
  84. <div v-if="detailData">
  85. <div class="totalPrice">总售价:¥<span>{{ toThousands(detailData.totalAmount) }}</span></div>
  86. <div>
  87. 产品总款数:<strong style="margin-right: 10px;"> {{ detailData.totalCategory }} </strong>
  88. 总数量:<strong style="margin-right: 10px;"> {{ detailData.totalQty }} </strong>
  89. <!-- 总售价:¥<strong> {{ toThousands(detailData.totalOrigAmount) }}</strong> -->
  90. <span style="margin:0 10px;" v-if="detailData.totalDiscountAmount">优惠金额:¥-<strong>{{ Number(detailData.totalDiscountAmount).toFixed(2) }}</strong></span>
  91. <a-popover title="优惠明细" @visibleChange="(visible)=>{visible&&getPromYhDetail()}">
  92. <a-button shape="round" size="small" v-if="detailData.totalDiscountAmount">优惠明细</a-button>
  93. <div slot="content">
  94. <div v-if="yhDetail">
  95. <div
  96. class="yhdetail"
  97. style="min-width:300px;margin-bottom: 5px;"
  98. v-for="(item,index) in yhDetail.promoMapList"
  99. :key="index">
  100. <div class="yhdetail-h" style="font-weight: bold;font-size:14px;">{{ item.description }}</div>
  101. <div
  102. style="padding-left:10px;"
  103. v-for="(sitem,sindex) in item.promoRuleMapList"
  104. :key="sindex"
  105. v-if="sitem.lossAmount"
  106. >
  107. <div style="display: flex;justify-content: space-between;">
  108. <span>{{ sitem.promotionRuleTypeDictValue }}:</span>
  109. <strong>¥{{ toThousands(sitem.lossAmount) }}</strong>
  110. </div>
  111. <div class="yhdetail-d" style="color:#999;">{{ sitem.description }}</div>
  112. </div>
  113. </div>
  114. <div class="yhdetail" style="display: flex;justify-content: space-between;">
  115. <span style="font-weight: bold;font-size:14px;">优惠金额:</span>
  116. <span style="font-weight: bold;font-size:18px;">¥{{ Number(yhDetail.totalLossAmount).toFixed(2) }}</span>
  117. </div>
  118. </div>
  119. <div style="text-align: center;padding: 20px;" v-else>
  120. 正在加载...
  121. </div>
  122. </div>
  123. </a-popover>
  124. </div>
  125. </div>
  126. </div>
  127. <div>
  128. <a-button
  129. size="large"
  130. style="padding: 0 40px;"
  131. :disabled="spinning"
  132. type="primary"
  133. class="button-primary"
  134. @click="handleSubmit()"
  135. id="productInfoList-handleSubmit">提交</a-button>
  136. </div>
  137. </div>
  138. <!-- 添加产品 -->
  139. <chooseProduct
  140. ref="chooseProduct"
  141. :openModal="showCpModal"
  142. @close="closeProductModal"
  143. @addProduct="insterProduct"></chooseProduct>
  144. <!-- 价格更新弹窗 -->
  145. <setPriceModal
  146. :show="priceUpdateModal"
  147. :totalRealAmount="updataData.totalRealAmount"
  148. :totalAmount="updataData.totalAmount"
  149. @ok="updatePrice"
  150. @cancel="priceUpdateModal=false"></setPriceModal>
  151. <!-- 新活动窗口 -->
  152. <newPromoModal
  153. :show="showNewActiveModal"
  154. :salesBillSn="salesBillSn"
  155. :newActiveList="newActiveList"
  156. @ok="showNewActiveOk"
  157. ></newPromoModal>
  158. </div>
  159. </template>
  160. <script>
  161. import { commonMixin } from '@/utils/mixin'
  162. import productList from './comps/productList.vue'
  163. import productNormalList from './comps/productNormalList.vue'
  164. import chooseProduct from './comps/chooseProduct.vue'
  165. import setPriceModal from './setPriceModal.vue'
  166. import newPromoModal from './newPromoModal.vue'
  167. import { salesDisablePromo, salesEnablePromoPromo, salesChangePromo } from '@/api/salesDetailNew'
  168. import { salesDetailBySn, salesPromoQueryCount, salesWriteSubmit, submitCheck, updateBatch, salesPromoQueryList, salesQueryUnPartPromo, salesPromoValidaSubmit } from '@/api/salesNew'
  169. export default {
  170. name: 'SalesNewEdit',
  171. mixins: [commonMixin],
  172. components: {
  173. setPriceModal,
  174. productList,
  175. chooseProduct,
  176. productNormalList,
  177. newPromoModal
  178. },
  179. data () {
  180. return {
  181. spinning: false,
  182. activeList: [], // 活动列表
  183. newActiveList: [], // 新活动列表
  184. activeDesKey: {},
  185. salesBillSn: null, // 销售单sn
  186. detailData: { discountAmount: 0, id: null, salesBillSn: '' }, // 订单基础数据
  187. warehouseSn: undefined,
  188. updataData: {
  189. totalRealAmount: '',
  190. totalAmount: ''
  191. },
  192. priceUpdateModal: false, // 价格更新弹窗
  193. showDetail: false,
  194. showCpModal: false,
  195. cpCurRefId: '',
  196. disabledActiveOption: null,
  197. yhDetail: null,
  198. showNewActiveModal: false
  199. }
  200. },
  201. computed: {
  202. showTotal () {
  203. return this.activeList.length > 0
  204. },
  205. shippingAddress () {
  206. const shippingAddrProvinceName = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddrProvinceName ? this.detailData.salesBillExtEntity.shippingAddrProvinceName : ''
  207. const shippingAddrCityName = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddrCityName ? this.detailData.salesBillExtEntity.shippingAddrCityName : ''
  208. const shippingAddrCountyName = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddrCountyName ? this.detailData.salesBillExtEntity.shippingAddrCountyName : ''
  209. const shippingAddr = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddr ? this.detailData.salesBillExtEntity.shippingAddr : ''
  210. if (!shippingAddrProvinceName && !shippingAddrCityName && !shippingAddrCountyName && !shippingAddr) {
  211. return '--'
  212. } else {
  213. return shippingAddrProvinceName + shippingAddrCityName + shippingAddrCountyName + shippingAddr
  214. }
  215. }
  216. },
  217. methods: {
  218. // 返回
  219. handleBack () {
  220. this.$router.push({ name: 'salesQueryNewList', query: { closeLastOldTab: true } })
  221. },
  222. tooglePanel (item) {
  223. item.isActive = !item.isActive
  224. this.activeList.splice()
  225. // 刷新当前表格
  226. if (item.isActive) {
  227. const row = this.$refs['productList-' + item.promoRuleSn][0]
  228. row && row.resetSearchForm()
  229. }
  230. },
  231. // 销售单详情
  232. getOrderDetail (flag, callback) {
  233. salesDetailBySn({ salesBillSn: this.$route.params.sn }).then(res => {
  234. if (res.status == 200) {
  235. this.detailData = res.data
  236. this.detailData.totalDiscountAmount = Number(this.detailData.totalOrigAmount || 0) - Number(this.detailData.totalAmount || 0)
  237. if (callback) {
  238. callback()
  239. }
  240. }
  241. if (flag) {
  242. this.getActiveList()
  243. }
  244. })
  245. },
  246. // 优惠明细查看
  247. getPromYhDetail () {
  248. salesPromoQueryCount({ salesBillSn: this.$route.params.sn }).then(res => {
  249. if (res.status == 200) {
  250. this.yhDetail = res.data
  251. }
  252. })
  253. },
  254. // 判断是否全部调用完
  255. isAllLoadFinish (mlist) {
  256. const nid = setInterval(() => {
  257. const ret = []
  258. mlist.map(item => {
  259. const da = item.disabled
  260. ret.push(da)
  261. })
  262. // 加载完了
  263. if (!ret.includes(true)) {
  264. clearInterval(nid)
  265. this.spinning = false
  266. }
  267. console.log(ret)
  268. }, 50)
  269. },
  270. // 刷新所有表格数据
  271. updateAllTable (flag) {
  272. const activeList = this.activeList.filter(item => item.isActive)
  273. const mlist = []
  274. this.spinning = true
  275. // 加载正常产品列表
  276. this.$refs.productNormalList.resetSearchForm()
  277. mlist.push(this.$refs.productNormalList)
  278. // 刷新所有活动产品列表
  279. activeList.map(item => {
  280. const row = this.$refs['productList-' + item.promoRuleSn][0]
  281. row && row.resetSearchForm()
  282. mlist.push(row)
  283. })
  284. // 判断是否全部调用完
  285. this.isAllLoadFinish(mlist)
  286. // 是否刷新详情
  287. if (flag) {
  288. this.getOrderDetail()
  289. }
  290. },
  291. // 获取销售单参与的活动列表
  292. async getActiveList () {
  293. // 已参与活动列表
  294. const list = await salesPromoQueryList({ salesBillSn: this.$route.params.sn }).then(res => res.data || [])
  295. this.activeList = list.filter(item => item.promotion && item.promotionRule)
  296. this.activeList.map(item => {
  297. item.isActive = item.enabledFlag == 1
  298. item.showDesc = false
  299. item.disabled = item.enabledFlag == 0
  300. this.activeDesKey['search-' + item.promoRuleSn] = false
  301. })
  302. setTimeout(() => {
  303. this.updateAllTable()
  304. }, 500)
  305. },
  306. // 获取是否有新活动
  307. async getNewActive () {
  308. const hasNewActive = await salesQueryUnPartPromo({ salesBillSn: this.$route.params.sn, enabledFlag: '1' }).then(res => res.data)
  309. if (hasNewActive.length) {
  310. this.newActiveList = hasNewActive
  311. this.showNewActiveModal = true
  312. }
  313. },
  314. showNewActiveOk () {
  315. this.showNewActiveModal = false
  316. this.getOrderDetail(true)
  317. },
  318. // 添加产品,包括正常和活动的产品
  319. closeProductModal (type) {
  320. this.cpCurRefId = ''
  321. this.showCpModal = false
  322. // 刷新表格
  323. // this.insterActiveOk(['normal','promo'][type])
  324. },
  325. // 打开选择产品弹框
  326. openProductModal (type, refId, countData) {
  327. console.log(type, refId, countData)
  328. const promo = this.activeList.find(item => item.promoRuleSn == refId)
  329. if (promo) {
  330. promo.countData = countData
  331. }
  332. this.$refs.chooseProduct.pageInit(this.detailData, promo, type)
  333. this.cpCurRefId = 'productList-' + refId
  334. this.showCpModal = true
  335. },
  336. // 添加活动产品成功的回调
  337. insterActiveOk (type) {
  338. console.log(type)
  339. const mlist = []
  340. this.spinning = true
  341. if (type == 'promo') {
  342. // 刷新正常产品列表
  343. this.$refs.productNormalList.resetSearchForm()
  344. mlist.push(this.$refs.productNormalList)
  345. }
  346. if (type == 'normal') {
  347. // 刷新活动产品列表
  348. const activeList = this.activeList.filter(item => item.isActive)
  349. activeList.map(item => {
  350. const row = this.$refs['productList-' + item.promoRuleSn][0]
  351. row && row.resetSearchForm()
  352. mlist.push(row)
  353. })
  354. }
  355. // 判断是否全部调用完
  356. this.isAllLoadFinish(mlist)
  357. this.getOrderDetail()
  358. },
  359. // 新增产品
  360. insterProduct (row, promotionFlag, type) {
  361. // 正常产品
  362. if (type == 0) {
  363. this.$refs.productNormalList.insterProduct(row, promotionFlag)
  364. } else {
  365. // 活动产品
  366. this.$refs[this.cpCurRefId][0].insterProduct(row, promotionFlag, type)
  367. }
  368. },
  369. // 更换活动
  370. upActive (oldPromo, data, params) {
  371. const promo = data.split('-')
  372. const newSn = this.activeList.find(item => item.promoRuleSn == promo[1])
  373. const newSalesPromoSn = newSn && newSn.salesPromoSn || ''
  374. salesChangePromo({
  375. salesPromoSn: data != 0 ? newSalesPromoSn : '',
  376. promoRuleSn: promo[1],
  377. promotionFlag: promo[2] || '',
  378. ...params
  379. }).then(res => {
  380. if (res.status == 200) {
  381. const mlist = []
  382. this.spinning = true
  383. // 刷新新参与活动
  384. if (data != 0) {
  385. const nt = this.$refs['productList-' + promo[1]][0]
  386. nt && nt.resetSearchForm()
  387. mlist.push(nt)
  388. }
  389. // 刷新正常活动
  390. const pnt = this.$refs.productNormalList
  391. pnt && pnt.resetSearchForm()
  392. mlist.push(pnt)
  393. // 刷新当前活动
  394. const ot = this.$refs['productList-' + oldPromo.promoRuleSn][0]
  395. ot && ot.upAcitveSuccess()
  396. mlist.push(ot)
  397. // 判断是否全部调用完
  398. this.isAllLoadFinish(mlist)
  399. // 刷新详情统计
  400. this.getOrderDetail()
  401. }
  402. })
  403. },
  404. // 选择价格类型 并更新
  405. updatePrice (type) {
  406. const ajax_data = {
  407. salesBillSn: this.salesBillSn,
  408. productPriceChangeFlag: type
  409. }
  410. if (type == 0) {
  411. this.submitResult(ajax_data)
  412. } else {
  413. updateBatch(this.updataData.detailList).then(res => {
  414. this.priceUpdateModal = false
  415. if (res.status == 200) {
  416. // 刷新详情统计
  417. this.spinning = true
  418. this.getOrderDetail(false, () => {
  419. this.submitResult(ajax_data)
  420. })
  421. }
  422. })
  423. }
  424. },
  425. // 提交销售单
  426. handleSubmit () {
  427. // 先不提交,先判断是否有价格更新 (下级创建时判断)
  428. if (this.detailData && this.detailData.salesBillSource == 'PURCHASE') {
  429. submitCheck({ salesBillSn: this.salesBillSn }).then(res => {
  430. if (res.status == 200) {
  431. if (res.data.detailList.length > 0) {
  432. this.updataData = res.data
  433. this.$nextTick(() => {
  434. this.priceUpdateModal = true
  435. })
  436. } else {
  437. this.submitResult({ salesBillSn: this.salesBillSn })
  438. }
  439. }
  440. })
  441. } else {
  442. this.submitResult({ salesBillSn: this.salesBillSn })
  443. }
  444. },
  445. // 提交销售单
  446. async submitResult (data) {
  447. const _this = this
  448. // 校验活动规则
  449. const vaildActive = await salesPromoValidaSubmit({ salesBillSn: this.salesBillSn }).then(res => res.data)
  450. // console.log(vaildActive)
  451. const a = vaildActive.filter(item => item.type == 1) // 不可提交
  452. const b = vaildActive.filter(item => item.type == 0) // 可跳过继续提交
  453. // 弹出不符合规则弹框,不可提交
  454. if (a.length) {
  455. this.$info({
  456. title: '提示',
  457. centered: true,
  458. class: 'confirm-center',
  459. okText: '关闭',
  460. width: 600,
  461. content: <div style="padding-top:15px;">
  462. <ol>
  463. {a.map(item => (
  464. <li style="padding:3px 0;">{item.message}</li>
  465. ))}
  466. </ol>
  467. <div style="padding:10px 0;text-align:center"><strong>请按照以上提示修改后再提交</strong></div>
  468. </div>
  469. })
  470. this.spinning = false
  471. } else {
  472. // 弹出确认提示信息,可跳过继续提交
  473. if (b.length) {
  474. this.$confirm({
  475. title: '提示',
  476. centered: true,
  477. class: 'confirm-center',
  478. okText: '提交',
  479. width: 600,
  480. content: <div style="padding-top:15px;">
  481. <ol>
  482. {b.map(item => (
  483. <li style="padding:3px 0;">{item.message}</li>
  484. ))}
  485. </ol>
  486. </div>,
  487. onOk () {
  488. _this.submitOrder(data)
  489. }
  490. })
  491. this.spinning = false
  492. } else {
  493. _this.submitOrder(data)
  494. }
  495. }
  496. },
  497. async submitOrder (data) {
  498. this.spinning = true
  499. const res = await salesWriteSubmit(data)
  500. if (res.status == 200) {
  501. this.handleBack()
  502. this.$message.success(res.message)
  503. }
  504. this.spinning = false
  505. },
  506. // 展开收缩活动详情
  507. showDesc (e, item) {
  508. e.stopPropagation()
  509. const row = this.$refs['productList-' + item.promoRuleSn][0]
  510. item.promotionRule.minOrderAmount = item.promotion.minOrderAmount ? Number(item.promotion.minOrderAmount).toFixed(2) : ''
  511. item.promotionRule.upperLimitAmount = item.promotion.upperLimitAmount ? Number(item.promotion.upperLimitAmount).toFixed(2) : ''
  512. row && row.showDesc(item.promotionRule)
  513. },
  514. showDescOk (v, item) {
  515. item.showDesc = v
  516. if (!item.isActive) {
  517. const row = this.$refs['productList-' + item.promoRuleSn][0]
  518. row && row.resetSearchForm()
  519. item.isActive = true
  520. }
  521. this.activeList.splice()
  522. },
  523. // 启用规则
  524. enabledActive (e, item) {
  525. const _this = this
  526. this.spinning = true
  527. salesEnablePromoPromo({
  528. salesBillSn: _this.salesBillSn,
  529. salesPromoSn: item.salesPromoSn
  530. }).then(res => {
  531. if (res.status == 200) {
  532. item.disabled = false
  533. item.isActive = true
  534. _this.activeList.splice()
  535. // 禁用按钮
  536. _this.$refs['productList-' + item.promoRuleSn][0].disableActive(false)
  537. // 刷新所有表格
  538. _this.updateAllTable(true)
  539. _this.spinning = false
  540. _this.$message.success('操作成功,请添加产品')
  541. }
  542. })
  543. },
  544. // 禁用规则
  545. disabledActive (e, item) {
  546. const _this = this
  547. _this.spinning = true
  548. salesDisablePromo({
  549. salesBillSn: _this.salesBillSn,
  550. salesPromoSn: item.salesPromoSn,
  551. promoRuleSn: item.promoRuleSn,
  552. salesDisableType: _this.disabledActiveOption
  553. }).then(res => {
  554. if (res.status == 200) {
  555. item.disabled = true
  556. item.isActive = false
  557. _this.activeList.splice()
  558. // 启用按钮
  559. _this.$refs['productList-' + item.promoRuleSn][0].disableActive(true)
  560. // 刷新所有表格
  561. _this.updateAllTable(true)
  562. _this.disabledActiveOption = null
  563. _this.spinning = false
  564. _this.$message.success('操作成功')
  565. }
  566. })
  567. },
  568. // 禁用启用活动规则
  569. disenablePromp (e, item) {
  570. const _this = this
  571. const table = _this.$refs['productList-' + item.promoRuleSn][0]
  572. // 是否启用规则
  573. if (item.disabled) {
  574. this.enabledActive(e, item)
  575. return
  576. }
  577. // 如果没有活动产品,直接禁用无需弹框提示
  578. if (!table.countData || table.countData && !table.countData.totalQty) {
  579. _this.disabledActiveOption = 'DELETE'
  580. _this.disabledActive(e, item)
  581. return
  582. }
  583. // 弹框提示禁用方式
  584. this.$confirm({
  585. title: '确定禁用规则?',
  586. centered: true,
  587. class: 'confirm-center',
  588. content: <div>
  589. <div style="padding:10px 0;text-align:center;">禁用规则后,将无法享受该活动规则优惠</div>
  590. <div style="padding:0 0 10px 0;text-align:center;">
  591. <aRadioGroup onChange={_this.changeDaOpt}>
  592. <aRadio style="display:block;height: '30px';lineHeight: '30px';padding:5px 0;" value="DELETE">
  593. 删除规则中相关产品
  594. </aRadio>
  595. <aRadio style="display:block;height: '30px';lineHeight: '30px';padding:5px 0;" value="REMOVE">
  596. 移出规则中相关产品
  597. </aRadio>
  598. </aRadioGroup>
  599. </div>
  600. </div>,
  601. onOk () {
  602. if (_this.disabledActiveOption) {
  603. _this.disabledActive(e, item)
  604. } else {
  605. _this.$message.info('请选择禁用方式!')
  606. return true
  607. }
  608. },
  609. onCancel () {
  610. _this.disabledActiveOption = null
  611. }
  612. })
  613. },
  614. changeDaOpt (e) {
  615. this.disabledActiveOption = e.target.value
  616. },
  617. pageInit () {
  618. this.salesBillSn = this.$route.params.sn
  619. this.warehouseSn = this.$route.params.sn ? this.$route.params.wSn : ''
  620. this.getOrderDetail(true)
  621. this.getNewActive()
  622. }
  623. },
  624. mounted () {
  625. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  626. this.pageInit()
  627. }
  628. },
  629. activated () {
  630. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  631. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  632. this.pageInit()
  633. }
  634. },
  635. beforeRouteEnter (to, from, next) {
  636. next(vm => {})
  637. }
  638. }
  639. </script>
  640. <style lang="less">
  641. .salesNewEdit-wrap{
  642. position: relative;
  643. height: 100%;
  644. padding-bottom: 65px;
  645. box-sizing: border-box;
  646. >.ant-spin-nested-loading{
  647. overflow-y: auto;
  648. height: 100%;
  649. }
  650. .salesEdit-cont{
  651. margin: 6px 0;
  652. }
  653. .redStyle{
  654. font-weight: bold;
  655. color: red;
  656. }
  657. .ellipsisCon{
  658. display: flex;
  659. justify-content: space-between;
  660. align-items: center;
  661. .ellipsisText{
  662. width: 100%;
  663. overflow: hidden;
  664. text-overflow: ellipsis;
  665. display: box;
  666. display: -webkit-box;
  667. -webkit-line-clamp: 1;
  668. -webkit-box-orient: vertical;
  669. }
  670. }
  671. .ant-card-small > .ant-card-body {
  672. padding: 0!important;
  673. }
  674. .affix-cont{
  675. padding: 6px 12px;
  676. text-align: right;
  677. display: flex;
  678. justify-content: space-between;
  679. align-items: center;
  680. .footer-price{
  681. flex-grow:1;
  682. display: flex;
  683. justify-content: flex-end;
  684. align-items: center;
  685. > div{
  686. padding: 0 15px;
  687. }
  688. .totalPrice{
  689. span{
  690. font-weight: bold;
  691. color: red;
  692. font-size: 20px;
  693. }
  694. }
  695. }
  696. }
  697. }
  698. </style>