edit.vue 27 KB

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