edit.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <div class="waitDispatch-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="waitDispatch-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 style="margin: 0 15px;color: #666;">客户名称:{{ detailData&&detailData.buyerName || '--' }}</span>
  10. </template>
  11. </a-page-header>
  12. <a-card size="small" :bordered="false" class="waitDispatch-cont">
  13. <!-- 查询配件列表 -->
  14. <queryPart
  15. ref="partQuery"
  16. :newLoading="isInster"
  17. :activeList="activeList"
  18. @cancelProduct="cancelProduct"
  19. @cancelAll="cancelAll"
  20. @convertPromoGifts="convertPromoGifts"
  21. @addProduct="insterProduct"></queryPart>
  22. </a-card>
  23. <a-card size="small" :bordered="false" class="waitDispatch-cont">
  24. <div slot="title">
  25. <div class="p-title">
  26. 待下推产品
  27. </div>
  28. </div>
  29. <!-- 已选配件列表 -->
  30. <detailProductList ref="waitProduct" @refashTable="refashTable">
  31. <!-- 统计数据 -->
  32. <template slot="total">
  33. 本次下推款数:<strong>{{ totalData&&(totalData.totalCategory || totalData.totalCategory==0) ? totalData.totalCategory : '--' }}</strong>;
  34. 本次下推数量:<strong>{{ totalData&&(totalData.totalQty || totalData.totalQty==0) ? totalData.totalQty : '--' }}</strong>;
  35. </template>
  36. </detailProductList>
  37. </a-card>
  38. </a-spin>
  39. <div class="affix-cont">
  40. <a-button
  41. style="padding: 0 50px;"
  42. :disabled="spinning"
  43. type="primary"
  44. size="large"
  45. class="button-primary"
  46. @click="handleDispatch()"
  47. :loading="loading"
  48. id="waitDispatch-handleSubmit">下推</a-button>
  49. </div>
  50. <!-- 下推 -->
  51. <dsModal ref="dsModal" :openModal="showDsModal" @close="showDsModal=false" @ok="handleSubmit" />
  52. </div>
  53. </template>
  54. <script>
  55. import { commonMixin } from '@/utils/mixin'
  56. import { VSelect } from '@/components'
  57. import queryPart from './queryPart.vue'
  58. import detailProductList from './detailProductList.vue'
  59. import dsModal from './dsModal.vue'
  60. // 接口
  61. import { salesDetailBySn, salesPromoQueryList } from '@/api/salesNew'
  62. import { insertBatchOfWaitDispatch, salesDetailUpdateCancelQty, salesDetailCancleOfAll, batchTransferOfPurchaseAmount } from '@/api/salesDetailNew'
  63. import { pushDown } from '@/api/waitDispatchDetail'
  64. import { findBySalesBillSn } from '@/api/dispatch'
  65. export default {
  66. name: 'WaitDispatch',
  67. mixins: [commonMixin],
  68. components: { detailProductList, VSelect, queryPart, dsModal },
  69. data () {
  70. return {
  71. showDsModal: false, // 下推弹框
  72. spinning: false,
  73. salesBillSn: null, // 销售单sn
  74. disabled: false, // 查询、重置按钮是否可操作
  75. isInster: false, // 是否正在添加产品
  76. delLoading: false, // 是否正在移除产品
  77. loading: false, // 是否下推中
  78. detailData: { discountAmount: 0, id: null, salesBillSn: '' }, // 订单基础数据
  79. productForm: {
  80. dispatchBillSn: '' // 下推单sn
  81. },
  82. totalData: null, // 统计数据
  83. activeList: [] // 参与活动列表
  84. }
  85. },
  86. methods: {
  87. // 返回
  88. handleBack () {
  89. this.$router.push({ name: 'salesQueryNewList', query: { closeLastOldTab: true } })
  90. },
  91. // 统计查询
  92. getTotalData (flag) {
  93. findBySalesBillSn({ salesBillSn: this.$route.params.salesBillSn }).then(res => {
  94. if (res.status == 200) {
  95. this.totalData = res.data || null
  96. if (res.data && Object.keys(res.data).length > 0) {
  97. this.productForm.dispatchBillSn = res.data.dispatchBillSn
  98. const _this = this
  99. if (flag) {
  100. _this.$refs.waitProduct.pageInit(this.productForm, this.detailData, this.activeList)
  101. } else {
  102. _this.$refs.waitProduct.resetSearchForm()
  103. }
  104. }
  105. } else {
  106. this.totalData = null
  107. }
  108. })
  109. },
  110. // 添加产品
  111. insterProduct (list) {
  112. // 防止多次添加产品
  113. if (this.isInster) { return }
  114. this.saveNewProduct(list)
  115. },
  116. // 保存添加的产品到下推列表
  117. saveNewProduct (list) {
  118. this.$message.loading('正在添加产品...', 1)
  119. this.isInster = true
  120. this.spinning = true
  121. insertBatchOfWaitDispatch({
  122. salesBillDetailSnList: list,
  123. salesBillSn: this.salesBillSn
  124. }).then(res => {
  125. if (res.status == 200) {
  126. this.refashTable(true)
  127. this.$refs.partQuery.clearSelectTable()
  128. this.$message.success('添加成功', 2.5)
  129. this.spinning = false
  130. } else {
  131. this.spinning = false
  132. }
  133. this.isInster = false
  134. })
  135. },
  136. // 整单取消
  137. cancelAll () {
  138. salesDetailCancleOfAll({ salesBillSn: this.salesBillSn }).then(res => {
  139. if (res.status == 200) {
  140. this.handleBack()
  141. this.$message.success(res.message)
  142. }
  143. })
  144. },
  145. // 批量转采购额
  146. convertPromoGifts (list) {
  147. this.$message.loading('正在批量转采购额...', 1)
  148. this.isInster = true
  149. this.spinning = true
  150. batchTransferOfPurchaseAmount({
  151. salesBillDetailList: list,
  152. salesBillSn: this.salesBillSn
  153. }).then(res => {
  154. if (res.status == 200) {
  155. this.getOrderDetail()
  156. this.$message.success(res.message, 2.5)
  157. this.spinning = false
  158. } else {
  159. this.spinning = false
  160. }
  161. this.isInster = false
  162. })
  163. },
  164. // 批量取消产品
  165. cancelProduct (list) {
  166. // 防止多次添加产品
  167. this.$message.loading('正在批量取消产品...', 1)
  168. this.isInster = true
  169. this.spinning = true
  170. salesDetailUpdateCancelQty({
  171. salesBillDetailList: list,
  172. salesBillSn: this.salesBillSn
  173. }).then(res => {
  174. if (res.status == 200) {
  175. this.getOrderDetail()
  176. this.$message.success(res.message, 2.5)
  177. this.spinning = false
  178. } else {
  179. this.spinning = false
  180. }
  181. this.isInster = false
  182. })
  183. },
  184. // 刷新表格
  185. refashTable (flag) {
  186. this.getTotalData()
  187. if (flag) {
  188. this.getOrderDetail(false)
  189. }
  190. },
  191. // 销售单详情
  192. getOrderDetail (flag) {
  193. salesDetailBySn({ salesBillSn: this.salesBillSn }).then(res => {
  194. if (res.status == 200) {
  195. this.detailData = res.data
  196. if (flag) {
  197. // 初始化表格
  198. this.$refs.partQuery.pageInit(this.salesBillSn, this.detailData)
  199. } else {
  200. // 刷新表格
  201. this.$refs.partQuery.resetSearchForm(this.detailData)
  202. }
  203. }
  204. })
  205. },
  206. // 提交下推
  207. handleDispatch () {
  208. const dataSource = this.$refs.waitProduct.dataSource
  209. if (dataSource.length) {
  210. // 打开下推弹框
  211. this.showDsModal = true
  212. this.detailData.dispatchBillCount = this.totalData.dispatchBillCount
  213. this.detailData.receiverName = this.totalData.receiverName ? this.totalData.receiverName : ''
  214. this.detailData.receiverSn = this.totalData.receiverSn ? this.totalData.receiverSn : ''
  215. this.$refs.dsModal.setDetail(this.detailData)
  216. } else {
  217. this.$message.warning('请选择待下推产品')
  218. }
  219. },
  220. // 提交下推
  221. handleSubmit (data) {
  222. this.delLoading = true
  223. this.isInster = true
  224. this.loading = true
  225. this.spinning = true
  226. const params = Object.assign({ dispatchBillSn: this.productForm.dispatchBillSn }, data)
  227. pushDown(params).then(res => {
  228. if (res.status == 200) {
  229. this.handleBack()
  230. this.$message.success(res.message)
  231. }
  232. this.delLoading = false
  233. this.isInster = false
  234. this.loading = false
  235. this.spinning = false
  236. })
  237. },
  238. // 页面初始化
  239. async pageInit () {
  240. // 已参与活动列表
  241. const list = await salesPromoQueryList({ salesBillSn: this.$route.params.sn || this.bizSn }).then(res => res.data || [])
  242. this.activeList = list.filter(item => item.promotion && item.promotionRule)
  243. // 查询表格数据
  244. this.$refs.partQuery.clearSelectTable()
  245. this.salesBillSn = this.$route.params.salesBillSn
  246. this.getOrderDetail(true)
  247. this.getTotalData(true)
  248. }
  249. },
  250. mounted () {
  251. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  252. this.pageInit()
  253. }
  254. },
  255. activated () {
  256. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  257. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  258. this.pageInit()
  259. }
  260. },
  261. beforeRouteEnter (to, from, next) {
  262. next(vm => {})
  263. }
  264. }
  265. </script>
  266. <style lang="less">
  267. .waitDispatch-wrap{
  268. position: relative;
  269. height: 100%;
  270. padding-bottom: 51px;
  271. box-sizing: border-box;
  272. >.ant-spin-nested-loading{
  273. overflow-y: scroll;
  274. height: 100%;
  275. }
  276. .waitDispatch-cont{
  277. margin-top: 10px;
  278. }
  279. .p-title{
  280. font-weight: bold;
  281. }
  282. .p-notes{
  283. span{
  284. color: #FF9900;
  285. }
  286. }
  287. .total-bar{
  288. display: flex;
  289. align-items: center;
  290. justify-content: space-between;
  291. > div{
  292. &:last-child{
  293. display: flex;
  294. align-items: center;
  295. justify-content: space-between;
  296. > div{
  297. padding: 0 10px;
  298. }
  299. }
  300. }
  301. }
  302. .redBg-row{
  303. background-color: #f5cdc8;
  304. }
  305. }
  306. </style>