edit.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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. @cancelProduct="cancelProduct"
  18. @cancelAll="cancelAll"
  19. @convertPromoGifts="convertPromoGifts"
  20. @addProduct="insterProduct"
  21. @updateStockType="updateStockType"
  22. ></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 } 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. }
  85. },
  86. methods: {
  87. // 返回
  88. handleBack () {
  89. this.$router.push({ name: 'salesQueryNewList', query: { closeLastOldTab: true } })
  90. },
  91. // 统计查询
  92. getTotalData (flag) {
  93. const _this = this
  94. findBySalesBillSn({ salesBillSn: this.$route.params.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. if (flag) {
  100. _this.$refs.waitProduct.pageInit(this.productForm, this.detailData, this.$refs.partQuery.activeList)
  101. } else {
  102. _this.$refs.waitProduct.resetSearchForm()
  103. }
  104. }
  105. } else {
  106. this.totalData = null
  107. }
  108. })
  109. },
  110. // 更新轮胎库存类型
  111. updateStockType (val) {
  112. this.spinning = true
  113. dispatchUpdateStockType({ stockType: val, dispatchBillSn: this.productForm.dispatchBillSn }).then(res => {
  114. if (res.status != 200) {
  115. this.$refs.partQuery.stockType = val == 'LOCK_STOCK' ? 'CURRENT_STOCK' : 'LOCK_STOCK'
  116. }
  117. this.spinning = false
  118. })
  119. },
  120. // 禁用库存类型选项
  121. upStockType (hasLt) {
  122. this.$refs.partQuery.stockDisabled = hasLt
  123. if (hasLt) {
  124. this.$refs.partQuery.stockType = this.totalData.stockType
  125. }
  126. },
  127. // 添加产品
  128. insterProduct (list) {
  129. // 防止多次添加产品
  130. if (this.isInster) { return }
  131. this.saveNewProduct(list)
  132. },
  133. // 保存添加的产品到下推列表
  134. saveNewProduct (list) {
  135. this.$message.loading('正在添加产品...', 1)
  136. this.isInster = true
  137. this.spinning = true
  138. insertBatchOfWaitDispatch({
  139. salesBillDetailSnList: list,
  140. salesBillSn: this.salesBillSn
  141. }).then(res => {
  142. if (res.status == 200) {
  143. this.refashTable(true)
  144. this.$refs.partQuery.clearSelectTable()
  145. this.$message.success('添加成功', 2.5)
  146. this.spinning = false
  147. } else {
  148. this.spinning = false
  149. }
  150. this.isInster = false
  151. })
  152. },
  153. // 整单取消
  154. cancelAll () {
  155. salesDetailCancleOfAll({ salesBillSn: this.salesBillSn }).then(res => {
  156. if (res.status == 200) {
  157. this.handleBack()
  158. this.$message.success(res.message)
  159. }
  160. })
  161. },
  162. // 批量转采购额
  163. convertPromoGifts (list) {
  164. this.$message.loading('正在批量转采购额...', 1)
  165. this.isInster = true
  166. this.spinning = true
  167. batchTransferOfPurchaseAmount({
  168. salesBillDetailList: list,
  169. salesBillSn: this.salesBillSn
  170. }).then(res => {
  171. if (res.status == 200) {
  172. this.getOrderDetail()
  173. this.$message.success(res.message, 2.5)
  174. this.spinning = false
  175. } else {
  176. this.spinning = false
  177. }
  178. this.isInster = false
  179. })
  180. },
  181. // 批量取消产品
  182. cancelProduct (list) {
  183. // 防止多次添加产品
  184. this.$message.loading('正在批量取消产品...', 1)
  185. this.isInster = true
  186. this.spinning = true
  187. salesDetailUpdateCancelQty({
  188. salesBillDetailList: list,
  189. salesBillSn: this.salesBillSn
  190. }).then(res => {
  191. if (res.status == 200) {
  192. this.getOrderDetail()
  193. this.$message.success(res.message, 2.5)
  194. this.spinning = false
  195. } else {
  196. this.spinning = false
  197. }
  198. this.isInster = false
  199. })
  200. },
  201. // 刷新表格
  202. refashTable (flag) {
  203. this.getTotalData()
  204. if (flag) {
  205. this.getOrderDetail(false)
  206. }
  207. },
  208. // 销售单详情
  209. getOrderDetail (flag) {
  210. salesDetailBySn({ salesBillSn: this.salesBillSn }).then(res => {
  211. if (res.status == 200) {
  212. this.detailData = res.data
  213. if (flag) {
  214. // 初始化表格
  215. this.$refs.partQuery.pageInit(this.salesBillSn, this.detailData)
  216. } else {
  217. // 刷新表格
  218. this.$refs.partQuery.resetSearchForm(this.detailData)
  219. }
  220. }
  221. })
  222. },
  223. // 提交下推
  224. handleDispatch () {
  225. const dataSource = this.$refs.waitProduct.dataSource
  226. if (dataSource.length) {
  227. // 打开下推弹框
  228. this.showDsModal = true
  229. this.detailData.dispatchBillCount = this.totalData.dispatchBillCount
  230. this.detailData.receiverName = this.totalData.receiverName ? this.totalData.receiverName : ''
  231. this.detailData.receiverSn = this.totalData.receiverSn ? this.totalData.receiverSn : ''
  232. this.$refs.dsModal.setDetail(this.detailData)
  233. } else {
  234. this.$message.warning('请选择待下推产品')
  235. }
  236. },
  237. // 提交下推
  238. handleSubmit (data) {
  239. this.delLoading = true
  240. this.isInster = true
  241. this.loading = true
  242. this.spinning = true
  243. const params = Object.assign({ dispatchBillSn: this.productForm.dispatchBillSn }, data)
  244. pushDown(params).then(res => {
  245. if (res.status == 200) {
  246. this.handleBack()
  247. this.$message.success(res.message)
  248. }
  249. this.delLoading = false
  250. this.isInster = false
  251. this.loading = false
  252. this.spinning = false
  253. })
  254. },
  255. // 页面初始化
  256. pageInit () {
  257. this.$refs.partQuery.clearSelectTable()
  258. this.salesBillSn = this.$route.params.salesBillSn
  259. this.getOrderDetail(true)
  260. this.getTotalData(true)
  261. }
  262. },
  263. mounted () {
  264. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  265. this.pageInit()
  266. }
  267. },
  268. activated () {
  269. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  270. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  271. this.pageInit()
  272. }
  273. },
  274. beforeRouteEnter (to, from, next) {
  275. next(vm => {})
  276. }
  277. }
  278. </script>
  279. <style lang="less">
  280. .waitDispatch-wrap{
  281. position: relative;
  282. height: 100%;
  283. padding-bottom: 51px;
  284. box-sizing: border-box;
  285. >.ant-spin-nested-loading{
  286. overflow-y: scroll;
  287. height: 100%;
  288. }
  289. .waitDispatch-cont{
  290. margin-top: 10px;
  291. }
  292. .p-title{
  293. font-weight: bold;
  294. }
  295. .p-notes{
  296. span{
  297. color: #FF9900;
  298. }
  299. }
  300. .total-bar{
  301. display: flex;
  302. align-items: center;
  303. justify-content: space-between;
  304. > div{
  305. &:last-child{
  306. display: flex;
  307. align-items: center;
  308. justify-content: space-between;
  309. > div{
  310. padding: 0 10px;
  311. }
  312. }
  313. }
  314. }
  315. .redBg-row{
  316. background-color: #f5cdc8;
  317. }
  318. }
  319. </style>