edit.vue 11 KB

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