chooseActive.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <a-modal
  3. centered
  4. :footer="null"
  5. :maskClosable="false"
  6. title="促销品列表"
  7. v-model="isShow"
  8. @cancle="cansel"
  9. width="80%">
  10. <a-card size="small" :bordered="false" class="productInfoList-wrap">
  11. <!-- 列表 -->
  12. <a-table
  13. class="sTable"
  14. ref="table"
  15. size="small"
  16. :row-selection="{
  17. selectedRowKeys: selectedRowKeys,
  18. onChange: onSelectChange,
  19. getCheckboxProps: record => ({
  20. props: {
  21. disabled: record.product.cost == undefined, // Column configuration not to be checked
  22. }
  23. })
  24. }"
  25. :rowKey="(record) => record.id"
  26. :columns="columns"
  27. :data-source="list"
  28. :loading="loading"
  29. :scroll="{ y: 350 }"
  30. bordered>
  31. <!-- 销售数量 -->
  32. <template slot="salesNums" slot-scope="text, record">
  33. <a-input-number
  34. size="small"
  35. :max="999999"
  36. :min="1"
  37. v-model="record.qty"
  38. :precision="0"
  39. :step="1"
  40. />
  41. </template>
  42. </a-table>
  43. <div style="display: flex;justify-content: center;padding: 10px 0;">
  44. <a-button
  45. size="large"
  46. type="primary"
  47. :loading="newLoading"
  48. class="button-primary"
  49. @click="handleSubmit"
  50. style="padding: 0 60px;">
  51. 确定
  52. </a-button>
  53. <a-button size="large" :loading="newLoading" style="padding: 0 60px;margin-left: 15px;font-size: 12px;" @click="cansel">
  54. 取消
  55. </a-button>
  56. </div>
  57. </a-card>
  58. </a-modal>
  59. </template>
  60. <script>
  61. import { STable, VSelect } from '@/components'
  62. import { getPromoGoodsList } from '@/api/salesDetail'
  63. export default {
  64. name: 'ChooseProduct',
  65. components: { STable, VSelect },
  66. props: {
  67. openModal: { // 弹框显示状态
  68. type: Boolean,
  69. default: false
  70. },
  71. buyerSn: {
  72. type: String,
  73. default: ''
  74. },
  75. newLoading: Boolean
  76. },
  77. data () {
  78. return {
  79. isShow: this.openModal,
  80. columns: [
  81. { title: '产品编码', dataIndex: 'product.code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  82. { title: '产品名称', dataIndex: 'product.name', align: 'center', customRender: function (text) { return text || '--' } },
  83. { title: '成本价', dataIndex: 'product.cost', align: 'center', customRender: function (text) { return '¥' + (text == undefined ? '--' : text) } },
  84. { title: '原售价', dataIndex: 'product.productPrice', align: 'center', customRender: function (text) { return '¥' + (text || 0) } },
  85. { title: '促销价', dataIndex: 'goodsPrice', align: 'center', customRender: function (text) { return '¥' + (text || 0) } },
  86. { title: '数量', dataIndex: 'qty', scopedSlots: { customRender: 'salesNums' }, align: 'center' },
  87. { title: '单位', dataIndex: 'product.unit', align: 'center', customRender: function (text) { return text || '--' } },
  88. { title: '促销类型', dataIndex: 'promoRuleTypeName', align: 'center', customRender: function (text) { return text || '--' } }
  89. ],
  90. selectedRowKeys: [], // Check here to configure the default column
  91. selectedRows: [],
  92. loading: false,
  93. list: [],
  94. salesBillDetailSn: null
  95. }
  96. },
  97. methods: {
  98. getData (row) {
  99. this.loading = true
  100. this.salesBillDetailSn = row.salesBillDetailSn
  101. getPromoGoodsList({ salesBillDetailSn: row.salesBillDetailSn, buyerSn: this.buyerSn }).then(res => {
  102. res.data.map(item => {
  103. item.qty = 1
  104. })
  105. this.list = res.data
  106. this.loading = false
  107. })
  108. },
  109. onSelectChange (selectedRowKeys, selectedRows) {
  110. this.selectedRowKeys = selectedRowKeys
  111. this.selectedRows = selectedRows
  112. },
  113. // 选择产品
  114. handleSubmit () {
  115. const _this = this
  116. if (_this.selectedRowKeys.length < 1) {
  117. _this.$message.warning('请选择促销品!')
  118. return
  119. }
  120. const obj = []
  121. _this.selectedRows.map(item => {
  122. obj.push({
  123. showCost: item.product.cost,
  124. price: item.goodsPrice,
  125. origPrice: item.product.productPrice,
  126. packQty: item.product.packQty,
  127. productSn: item.product.productSn,
  128. promotionSourceSn: this.salesBillDetailSn,
  129. promotionActivitySn: item.promoActiveSn,
  130. promotionActivityName: item.promoActiveName,
  131. promotionRules: item.promoRuleSn,
  132. promoGoodsType: item.promoGoodsType,
  133. qty: item.qty,
  134. promotableFlag: 0, // 可促销标记 有活动的传1,没活动的传0
  135. promotionFlag: 1 // 促销标记 正品传0,促销品传1
  136. })
  137. })
  138. _this.$emit('ok', obj)
  139. },
  140. cansel () {
  141. this.$emit('close')
  142. }
  143. },
  144. watch: {
  145. // 父页面传过来的弹框状态
  146. openModal (newValue, oldValue) {
  147. this.isShow = newValue
  148. },
  149. // 重定义的弹框状态
  150. isShow (newValue, oldValue) {
  151. if (!newValue) {
  152. this.$emit('close')
  153. }
  154. }
  155. }
  156. }
  157. </script>