edit.vue 9.6 KB

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