edit.vue 27 KB

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