grabOrderModal.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <a-modal
  3. centered
  4. :footer="null"
  5. title="选择退货单价"
  6. v-model="isShow"
  7. @cancel="isShow=false"
  8. width="50%">
  9. <a-spin :spinning="spinning" tip="Loading...">
  10. <a-table
  11. class="sTable"
  12. style="max-height:240px;"
  13. ref="table"
  14. size="small"
  15. :rowKey="(record) => record.productScopeSn"
  16. :columns="columns"
  17. :data-source="grabSalesList"
  18. :scroll="{ y: 200 }"
  19. :pagination="false"
  20. bordered
  21. >
  22. <template v-for="col in ['code','normalPrice', 'specialPrice', 'salesPrice']" :slot="col" slot-scope="text, record, index" >
  23. <div :key="col">
  24. <template v-if="col=='code'">
  25. <span>{{ text }}</span>
  26. </template>
  27. <div v-else>
  28. <a-radio-group name="radioGroup" v-model="record.resultVal">
  29. <div v-if="record.NORMAL&&col==='normalPrice'">
  30. <a-radio :value="record.NORMAL" >
  31. {{ record.NORMAL.price }}
  32. </a-radio>
  33. </div>
  34. <div v-else-if="record.DISCOUNT&&col==='specialPrice'">
  35. <a-radio :value="record.DISCOUNT" >
  36. {{ record.DISCOUNT.specialPrice }}
  37. </a-radio>
  38. </div>
  39. <div v-else-if="record.GIFT&&col==='salesPrice'">
  40. <a-radio :value="record.GIFT" >
  41. {{ record.GIFT.realSalePrice }}
  42. </a-radio>
  43. </div>
  44. <div v-else>--</div>
  45. </a-radio-group>
  46. </div>
  47. </div>
  48. </template>
  49. </a-table>
  50. <div class="btn-cont">
  51. <a-button id="sales-print-back" @click="handleCancel">取消</a-button>
  52. <a-button type="primary" id="sales-print-save" @click="handleSave" style="margin-left: 15px;">确定</a-button>
  53. </div>
  54. </a-spin>
  55. </a-modal>
  56. </template>
  57. <script>
  58. import { commonMixin } from '@/utils/mixin'
  59. import { VSelect, STable } from '@/components'
  60. import { grabSalesBill } from '@/api/salesReturn'
  61. export default {
  62. name: 'GrabOrderModal',
  63. mixins: [commonMixin],
  64. components: { VSelect, STable },
  65. props: {
  66. openModal: {
  67. type: Boolean,
  68. default: false
  69. },
  70. infoData: {
  71. type: Object,
  72. default: function () {
  73. return {}
  74. }
  75. }
  76. },
  77. data () {
  78. return {
  79. isShow: this.openModal,
  80. spinning: false,
  81. columns: [
  82. { title: '产品编码', dataIndex: 'product.code', width: '26%', scopedSlots: { customRender: 'code' }, align: 'center' },
  83. { title: '正常产品单价', width: '28%', scopedSlots: { customRender: 'normalPrice' }, align: 'center' },
  84. { title: '特价产品单价', width: '28%', scopedSlots: { customRender: 'specialPrice' }, align: 'center' },
  85. { title: '促销产品单价', width: '28%', scopedSlots: { customRender: 'salesPrice' }, align: 'center' }
  86. ],
  87. grabSalesList: []
  88. }
  89. },
  90. methods: {
  91. // 获取列表数据
  92. getDataList () {
  93. grabSalesBill(this.infoData).then(res => {
  94. this.grabSalesList = res.data
  95. })
  96. },
  97. // 重置选择
  98. reSetSelect () {
  99. this.grabSalesList.map(item => { item.resultVal = null })
  100. },
  101. // 取消
  102. handleCancel () {
  103. this.isShow = false
  104. },
  105. // 保存
  106. handleSave () {
  107. const flag = this.grabSalesList.some(item => !item.resultVal)
  108. if (flag) {
  109. this.$message.warning('未选择产品单价')
  110. return
  111. }
  112. const resultVal = this.grabSalesList.map(item => {
  113. const newobj = {
  114. salesReturnDetailSn: item.product.salesReturnDetailSn, salesBillDetailSn: item.resultVal.salesBillDetailSn
  115. }
  116. return newobj
  117. })
  118. this.$emit('ok', resultVal)
  119. this.isShow = false
  120. }
  121. },
  122. watch: {
  123. openModal (nVal, oVal) {
  124. this.isShow = nVal
  125. },
  126. isShow (nVal, oVal) {
  127. if (!nVal) {
  128. this.reSetSelect()
  129. this.$emit('close')
  130. } else {
  131. if (this.infoData) {
  132. this.getDataList()
  133. }
  134. }
  135. }
  136. }
  137. }
  138. </script>
  139. <style lang="less" scoped>
  140. .btn-cont {
  141. text-align: center;
  142. margin: 35px 0 10px;
  143. }
  144. </style>