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