edit.vue 27 KB

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