edit.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  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) {
  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. }
  238. if (flag) {
  239. this.getActiveList()
  240. }
  241. })
  242. },
  243. // 优惠明细查看
  244. getPromYhDetail () {
  245. salesPromoQueryCount({ salesBillSn: this.$route.params.sn }).then(res => {
  246. if (res.status == 200) {
  247. this.yhDetail = res.data
  248. }
  249. })
  250. },
  251. // 判断是否全部调用完
  252. isAllLoadFinish (mlist) {
  253. const nid = setInterval(() => {
  254. const ret = []
  255. mlist.map(item => {
  256. const da = item.disabled
  257. ret.push(da)
  258. })
  259. // 加载完了
  260. if (!ret.includes(true)) {
  261. clearInterval(nid)
  262. this.spinning = false
  263. }
  264. console.log(ret)
  265. }, 50)
  266. },
  267. // 刷新所有表格数据
  268. updateAllTable (flag) {
  269. const activeList = this.activeList.filter(item => item.isActive)
  270. const mlist = []
  271. this.spinning = true
  272. // 加载正常产品列表
  273. this.$refs.productNormalList.resetSearchForm()
  274. mlist.push(this.$refs.productNormalList)
  275. // 刷新所有活动产品列表
  276. activeList.map(item => {
  277. const row = this.$refs['productList-' + item.promoRuleSn][0]
  278. row && row.resetSearchForm()
  279. mlist.push(row)
  280. })
  281. // 判断是否全部调用完
  282. this.isAllLoadFinish(mlist)
  283. // 是否刷新详情
  284. if (flag) {
  285. this.getOrderDetail()
  286. }
  287. },
  288. // 获取销售单参与的活动列表
  289. async getActiveList () {
  290. // 已参与活动列表
  291. const list = await salesPromoQueryList({ salesBillSn: this.$route.params.sn }).then(res => res.data || [])
  292. this.activeList = list.filter(item => item.promotion && item.promotionRule)
  293. this.activeList.map(item => {
  294. item.isActive = item.enabledFlag == 1
  295. item.showDesc = false
  296. item.disabled = item.enabledFlag == 0
  297. this.activeDesKey['search-' + item.promoRuleSn] = false
  298. })
  299. setTimeout(() => {
  300. this.updateAllTable()
  301. }, 500)
  302. },
  303. // 获取是否有新活动
  304. async getNewActive () {
  305. const hasNewActive = await salesQueryUnPartPromo({ salesBillSn: this.$route.params.sn, enabledFlag: '1' }).then(res => res.data)
  306. if (hasNewActive.length) {
  307. this.newActiveList = hasNewActive
  308. this.showNewActiveModal = true
  309. }
  310. },
  311. showNewActiveOk () {
  312. this.showNewActiveModal = false
  313. this.getOrderDetail(true)
  314. },
  315. // 添加产品,包括正常和活动的产品
  316. closeProductModal (type) {
  317. this.cpCurRefId = ''
  318. this.showCpModal = false
  319. // 刷新表格
  320. // this.insterActiveOk(['normal','promo'][type])
  321. },
  322. // 打开选择产品弹框
  323. openProductModal (type, refId, countData) {
  324. console.log(type, refId, countData)
  325. const promo = this.activeList.find(item => item.promoRuleSn == refId)
  326. if(promo){
  327. promo.countData = countData
  328. }
  329. this.$refs.chooseProduct.pageInit(this.detailData, promo, type)
  330. this.cpCurRefId = 'productList-' + refId
  331. this.showCpModal = true
  332. },
  333. // 添加活动产品成功的回调
  334. insterActiveOk (type) {
  335. console.log(type)
  336. const mlist = []
  337. this.spinning = true
  338. if (type == 'promo') {
  339. // 刷新正常产品列表
  340. this.$refs.productNormalList.resetSearchForm()
  341. mlist.push(this.$refs.productNormalList)
  342. }
  343. if (type == 'normal') {
  344. // 刷新活动产品列表
  345. const activeList = this.activeList.filter(item => item.isActive)
  346. activeList.map(item => {
  347. const row = this.$refs['productList-' + item.promoRuleSn][0]
  348. row && row.resetSearchForm()
  349. mlist.push(row)
  350. })
  351. }
  352. // 判断是否全部调用完
  353. this.isAllLoadFinish(mlist)
  354. this.getOrderDetail()
  355. },
  356. // 新增产品
  357. insterProduct (row, promotionFlag, type) {
  358. // 正常产品
  359. if (type == 0) {
  360. this.$refs.productNormalList.insterProduct(row, promotionFlag)
  361. } else {
  362. // 活动产品
  363. this.$refs[this.cpCurRefId][0].insterProduct(row, promotionFlag, type)
  364. }
  365. },
  366. // 更换活动
  367. upActive (oldPromo, data, params) {
  368. const promo = data.split('-')
  369. const newSn = this.activeList.find(item => item.promoRuleSn == promo[1])
  370. const newSalesPromoSn = newSn && newSn.salesPromoSn || ''
  371. salesChangePromo({
  372. salesPromoSn: data != 0 ? newSalesPromoSn : '',
  373. promoRuleSn: promo[1],
  374. promotionFlag: promo[2] || '',
  375. ...params
  376. }).then(res => {
  377. if (res.status == 200) {
  378. const mlist = []
  379. this.spinning = true
  380. // 刷新新参与活动
  381. if (data != 0) {
  382. const nt = this.$refs['productList-' + promo[1]][0]
  383. nt && nt.resetSearchForm()
  384. mlist.push(nt)
  385. }
  386. // 刷新正常活动
  387. const pnt = this.$refs.productNormalList
  388. pnt && pnt.resetSearchForm()
  389. mlist.push(pnt)
  390. // 刷新当前活动
  391. const ot = this.$refs['productList-' + oldPromo.promoRuleSn][0]
  392. ot && ot.upAcitveSuccess()
  393. mlist.push(ot)
  394. // 判断是否全部调用完
  395. this.isAllLoadFinish(mlist)
  396. // 刷新详情统计
  397. this.getOrderDetail()
  398. }
  399. })
  400. },
  401. // 选择价格类型 并更新
  402. updatePrice (type) {
  403. const ajax_data = {
  404. salesBillSn: this.salesBillSn,
  405. productPriceChangeFlag: type
  406. }
  407. if (type == 0) {
  408. this.submitResult(ajax_data)
  409. } else {
  410. updateBatch(this.updataData.detailList).then(res => {
  411. if (res.status == 200) {
  412. this.submitResult(ajax_data)
  413. }
  414. })
  415. }
  416. },
  417. // 提交销售单
  418. handleSubmit () {
  419. // 先不提交,先判断是否有价格更新 (下级创建时判断)
  420. if (this.detailData && this.detailData.salesBillSource == 'PURCHASE') {
  421. submitCheck({ salesBillSn: this.salesBillSn }).then(res => {
  422. if (res.status == 200) {
  423. if (res.data.detailList.length > 0) {
  424. this.updataData = res.data
  425. this.$nextTick(() => {
  426. this.priceUpdateModal = true
  427. })
  428. } else {
  429. this.submitResult({ salesBillSn: this.salesBillSn })
  430. }
  431. }
  432. })
  433. } else {
  434. this.submitResult({ salesBillSn: this.salesBillSn })
  435. }
  436. },
  437. // 提交销售单
  438. async submitResult (data) {
  439. const _this = this
  440. // 校验活动规则
  441. const vaildActive = await salesPromoValidaSubmit({ salesBillSn: this.salesBillSn }).then(res => res.data)
  442. // console.log(vaildActive)
  443. const a = vaildActive.filter(item => item.type == 1) // 不可提交
  444. const b = vaildActive.filter(item => item.type == 0) // 可跳过继续提交
  445. // 弹出不符合规则弹框,不可提交
  446. if (a.length) {
  447. this.$info({
  448. title: '提示',
  449. centered: true,
  450. class: 'confirm-center',
  451. okText: '关闭',
  452. width: 600,
  453. content: <div style="padding-top:15px;">
  454. <ol>
  455. {a.map(item => (
  456. <li style="padding:3px 0;">{item.message}</li>
  457. ))}
  458. </ol>
  459. <div style="padding:10px 0;text-align:center"><strong>请按照以上提示修改后再提交</strong></div>
  460. </div>
  461. })
  462. } else {
  463. // 弹出确认提示信息,可跳过继续提交
  464. if (b.length) {
  465. this.$confirm({
  466. title: '提示',
  467. centered: true,
  468. class: 'confirm-center',
  469. okText: '提交',
  470. width: 600,
  471. content: <div style="padding-top:15px;">
  472. <ol>
  473. {b.map(item => (
  474. <li style="padding:3px 0;">{item.message}</li>
  475. ))}
  476. </ol>
  477. </div>,
  478. onOk () {
  479. _this.submitOrder(data)
  480. }
  481. })
  482. } else {
  483. _this.submitOrder(data)
  484. }
  485. }
  486. },
  487. async submitOrder (data) {
  488. this.spinning = true
  489. const res = await salesWriteSubmit(data)
  490. if (res.status == 200) {
  491. this.handleBack()
  492. this.$message.success(res.message)
  493. }
  494. this.spinning = false
  495. },
  496. // 展开收缩活动详情
  497. showDesc (e, item) {
  498. e.stopPropagation()
  499. const row = this.$refs['productList-' + item.promoRuleSn][0]
  500. item.promotionRule.minOrderAmount = item.promotion.minOrderAmount ? Number(item.promotion.minOrderAmount).toFixed(2) : ''
  501. item.promotionRule.upperLimitAmount = item.promotion.upperLimitAmount ? Number(item.promotion.upperLimitAmount).toFixed(2) : ''
  502. row && row.showDesc(item.promotionRule)
  503. },
  504. showDescOk (v, item) {
  505. item.showDesc = v
  506. if (!item.isActive) {
  507. const row = this.$refs['productList-' + item.promoRuleSn][0]
  508. row && row.resetSearchForm()
  509. item.isActive = true
  510. }
  511. this.activeList.splice()
  512. },
  513. // 启用规则
  514. enabledActive (e, item) {
  515. const _this = this
  516. this.spinning = true
  517. salesEnablePromoPromo({
  518. salesBillSn: _this.salesBillSn,
  519. salesPromoSn: item.salesPromoSn
  520. }).then(res => {
  521. if (res.status == 200) {
  522. item.disabled = false
  523. item.isActive = true
  524. _this.activeList.splice()
  525. // 禁用按钮
  526. _this.$refs['productList-' + item.promoRuleSn][0].disableActive(false)
  527. // 刷新所有表格
  528. _this.updateAllTable(true)
  529. _this.spinning = false
  530. _this.$message.success('操作成功,请添加产品')
  531. }
  532. })
  533. },
  534. // 禁用规则
  535. disabledActive (e, item) {
  536. const _this = this
  537. _this.spinning = true
  538. salesDisablePromo({
  539. salesBillSn: _this.salesBillSn,
  540. salesPromoSn: item.salesPromoSn,
  541. promoRuleSn: item.promoRuleSn,
  542. salesDisableType: _this.disabledActiveOption
  543. }).then(res => {
  544. if (res.status == 200) {
  545. item.disabled = true
  546. item.isActive = false
  547. _this.activeList.splice()
  548. // 启用按钮
  549. _this.$refs['productList-' + item.promoRuleSn][0].disableActive(true)
  550. // 刷新所有表格
  551. _this.updateAllTable(true)
  552. _this.disabledActiveOption = null
  553. _this.spinning = false
  554. _this.$message.success('操作成功')
  555. }
  556. })
  557. },
  558. // 禁用启用活动规则
  559. disenablePromp (e, item) {
  560. const _this = this
  561. const table = _this.$refs['productList-' + item.promoRuleSn][0]
  562. // 是否启用规则
  563. if (item.disabled) {
  564. this.enabledActive(e, item)
  565. return
  566. }
  567. // 如果没有活动产品,直接禁用无需弹框提示
  568. if (!table.countData || table.countData && !table.countData.totalQty) {
  569. _this.disabledActiveOption = 'DELETE'
  570. _this.disabledActive(e, item)
  571. return
  572. }
  573. // 弹框提示禁用方式
  574. this.$confirm({
  575. title: '确定禁用规则?',
  576. centered: true,
  577. class: 'confirm-center',
  578. content: <div>
  579. <div style="padding:10px 0;text-align:center;">禁用规则后,将无法享受该活动规则优惠</div>
  580. <div style="padding:0 0 10px 0;text-align:center;">
  581. <aRadioGroup onChange={_this.changeDaOpt}>
  582. <aRadio style="display:block;height: '30px';lineHeight: '30px';padding:5px 0;" value="DELETE">
  583. 删除规则中相关产品
  584. </aRadio>
  585. <aRadio style="display:block;height: '30px';lineHeight: '30px';padding:5px 0;" value="REMOVE">
  586. 移出规则中相关产品
  587. </aRadio>
  588. </aRadioGroup>
  589. </div>
  590. </div>,
  591. onOk () {
  592. if (_this.disabledActiveOption) {
  593. _this.disabledActive(e, item)
  594. } else {
  595. _this.$message.info('请选择禁用方式!')
  596. return true
  597. }
  598. },
  599. onCancel () {
  600. _this.disabledActiveOption = null
  601. }
  602. })
  603. },
  604. changeDaOpt (e) {
  605. this.disabledActiveOption = e.target.value
  606. },
  607. pageInit () {
  608. this.salesBillSn = this.$route.params.sn
  609. this.warehouseSn = this.$route.params.sn ? this.$route.params.wSn : ''
  610. this.getOrderDetail(true)
  611. this.getNewActive()
  612. }
  613. },
  614. mounted () {
  615. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  616. this.pageInit()
  617. }
  618. },
  619. activated () {
  620. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  621. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  622. this.pageInit()
  623. }
  624. },
  625. beforeRouteEnter (to, from, next) {
  626. next(vm => {})
  627. }
  628. }
  629. </script>
  630. <style lang="less">
  631. .salesNewEdit-wrap{
  632. position: relative;
  633. height: 100%;
  634. padding-bottom: 65px;
  635. box-sizing: border-box;
  636. >.ant-spin-nested-loading{
  637. overflow-y: auto;
  638. height: 100%;
  639. }
  640. .salesEdit-cont{
  641. margin: 6px 0;
  642. }
  643. .redStyle{
  644. font-weight: bold;
  645. color: red;
  646. }
  647. .ellipsisCon{
  648. display: flex;
  649. justify-content: space-between;
  650. align-items: center;
  651. .ellipsisText{
  652. width: 100%;
  653. overflow: hidden;
  654. text-overflow: ellipsis;
  655. display: box;
  656. display: -webkit-box;
  657. -webkit-line-clamp: 1;
  658. -webkit-box-orient: vertical;
  659. }
  660. }
  661. .ant-card-small > .ant-card-body {
  662. padding: 0!important;
  663. }
  664. .affix-cont{
  665. padding: 6px 12px;
  666. text-align: right;
  667. display: flex;
  668. justify-content: space-between;
  669. align-items: center;
  670. .footer-price{
  671. flex-grow:1;
  672. display: flex;
  673. justify-content: flex-end;
  674. align-items: center;
  675. > div{
  676. padding: 0 15px;
  677. }
  678. .totalPrice{
  679. span{
  680. font-weight: bold;
  681. color: red;
  682. font-size: 20px;
  683. }
  684. }
  685. }
  686. }
  687. }
  688. </style>