dealerStockModal.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <a-modal
  3. v-model="isShow"
  4. title="选择发货经销商"
  5. centered
  6. :maskClosable="false"
  7. :confirmLoading="confirmLoading"
  8. width="500px"
  9. :footer="null"
  10. @cancel="cancel">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <div style="padding: 0 30px;">
  13. <a-radio-group v-model="chooseVal">
  14. <!-- SUPERIORS 上级 purchase 省仓 -->
  15. <a-radio :style="radioStyle" v-for="(item,index) in dealerList" :key="item.dealerSn" :value="item.dealerSn">
  16. {{ item.dealerName }}{{ item.parentType?item.parentType==='SUPERIORS'?'(上级)':'(省仓)' :'' }}
  17. <dealerSubareaScopeList
  18. v-if="index==dealerList.length-1&&chooseVal=='a1'"
  19. dealertype="tire"
  20. placeholder="请输入发货经销商名称"
  21. ref="dealerSubareaScopeList"
  22. id="dealerStockModal-custList"
  23. style="margin-left:10px;width:280px;"
  24. @change="dealerChange" />
  25. </a-radio>
  26. </a-radio-group>
  27. </div>
  28. <div style="padding: 30px 0 0;text-align: center;">
  29. <a-button @click="cancel" style="margin-right: 15px" type="default" id="chooseCustom-btn-back">取消</a-button>
  30. <a-button type="primary" :loading="confirmLoading" @click="handleSubmit" id="chooseCustom-btn-submit">确定</a-button>
  31. </div>
  32. </a-spin>
  33. </a-modal>
  34. </template>
  35. <script>
  36. import { commonMixin } from '@/utils/mixin'
  37. import { querySuperiorDealer, queryTransferDealerStock } from '@/api/sales'
  38. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  39. export default {
  40. name: 'DealerStockModal',
  41. mixins: [commonMixin],
  42. props: {
  43. openModal: { // 弹框显示状态
  44. type: Boolean,
  45. default: false
  46. },
  47. itemSn: {
  48. type: String,
  49. default: ''
  50. }
  51. },
  52. components: { dealerSubareaScopeList },
  53. data () {
  54. return {
  55. isShow: this.openModal,
  56. spinning: false,
  57. confirmLoading: false,
  58. chooseVal: null,
  59. radioStyle: "display:block;height: '30px';lineHeight: '30px';padding:5px 0;",
  60. dealerList: [{ dealerName: '其他经销商', dealerSn: 'a1' }],
  61. salesBillSn: null,
  62. selectDealerSn: undefined, // 已选发货经销商
  63. selectDealerName: undefined
  64. }
  65. },
  66. methods: {
  67. getDealerList () {
  68. this.spinning = true
  69. querySuperiorDealer({ salesBillSn: this.itemSn }).then(res => {
  70. this.dealerList = res.data.concat(this.dealerList)
  71. // 默认选中第一项
  72. this.chooseVal = this.dealerList[0].dealerSn
  73. this.spinning = false
  74. })
  75. },
  76. // 选择经销商
  77. dealerChange (val) {
  78. if (val && val.key) {
  79. this.selectDealerSn = val.key
  80. this.selectDealerName = val.name
  81. }
  82. },
  83. // 保存
  84. handleSubmit (e) {
  85. e.preventDefault()
  86. const _this = this
  87. let chooseRow = []
  88. if (_this.chooseVal) {
  89. if (_this.chooseVal === 'a1') {
  90. if (!_this.selectDealerSn || !_this.selectDealerName) {
  91. _this.$message.warning('请选择发货经销商!')
  92. return
  93. }
  94. chooseRow.push({
  95. dealerSn: _this.selectDealerSn,
  96. dealerName: _this.selectDealerName
  97. })
  98. } else {
  99. chooseRow = _this.dealerList.filter(item => item.dealerSn == _this.chooseVal)
  100. }
  101. _this.confirmLoading = true
  102. queryTransferDealerStock({ salesBillSn: _this.itemSn, transferDealerSn: _this.chooseVal === 'a1' ? _this.selectDealerSn : _this.chooseVal }).then(res => {
  103. if (res.status == 200) {
  104. _this.confirmLoading = false
  105. _this.cancel()
  106. _this.$emit('ok', chooseRow[0], res.data)
  107. }
  108. })
  109. } else {
  110. _this.$message.info('请选择发货经销商类型!')
  111. }
  112. },
  113. cancel () {
  114. this.dealerList = [{ dealerName: '其他经销商', dealerSn: 'a1' }]
  115. if (this.$refs && Object.keys(this.$refs).length && this.chooseVal == 'a1') {
  116. this.$refs.dealerSubareaScopeList[0].resetForm()
  117. }
  118. this.chooseVal = null
  119. this.isShow = false
  120. }
  121. },
  122. watch: {
  123. // 父页面传过来的弹框状态
  124. openModal (newValue, oldValue) {
  125. this.isShow = newValue
  126. },
  127. // 重定义的弹框状态
  128. isShow (newValue, oldValue) {
  129. if (!newValue) {
  130. this.$emit('close')
  131. } else {
  132. if (this.itemSn && this.itemSn.length > 0) {
  133. this.getDealerList()
  134. }
  135. }
  136. }
  137. }
  138. }
  139. </script>