chooseActive.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <a-modal
  3. centered
  4. :footer="null"
  5. :maskClosable="false"
  6. title="促销品列表"
  7. v-model="isShow"
  8. @cancel="cansel"
  9. :width="960">
  10. <a-card size="small" :bordered="false" class="productInfoList-wrap">
  11. <!-- 列表 -->
  12. <s-table
  13. class="sTable"
  14. ref="table"
  15. size="small"
  16. :rowKey="(record) => record.id"
  17. :row-selection="{ columnWidth: 40, getCheckboxProps: record => ({ props: { disabled: record.cost == undefined||record.cost==0||record.productPrice==0||record.productPrice==undefined } }) }"
  18. @rowSelection="rowSelectionFun"
  19. :columns="columns"
  20. :data="loadData"
  21. :defaultLoadData="false"
  22. :scroll="{ x: 900, y: 350 }"
  23. bordered>
  24. <!-- 销售数量 -->
  25. <template slot="salesNums" slot-scope="text, record">
  26. <a-input-number
  27. size="small"
  28. :max="999999"
  29. :min="1"
  30. v-model="record.qty"
  31. :precision="0"
  32. :step="1"
  33. style="width: 100%;"
  34. />
  35. </template>
  36. </s-table>
  37. <div style="display: flex;justify-content: center;padding: 10px 0;">
  38. <a-button
  39. size="large"
  40. type="primary"
  41. :loading="newLoading"
  42. class="button-primary"
  43. @click="handleSubmit"
  44. style="padding: 0 60px;">
  45. 确定
  46. </a-button>
  47. <a-button size="large" :loading="newLoading" style="padding: 0 60px;margin-left: 15px;font-size: 12px;" @click="cansel">
  48. 取消
  49. </a-button>
  50. </div>
  51. </a-card>
  52. </a-modal>
  53. </template>
  54. <script>
  55. import { commonMixin } from '@/utils/mixin'
  56. import { STable, VSelect } from '@/components'
  57. import { getPromoGoodsList } from '@/api/salesDetail'
  58. export default {
  59. name: 'SalesChooseActiveProduct',
  60. mixins: [commonMixin],
  61. components: { STable, VSelect },
  62. props: {
  63. openModal: { // 弹框显示状态
  64. type: Boolean,
  65. default: false
  66. },
  67. newLoading: Boolean
  68. },
  69. data () {
  70. return {
  71. isShow: this.openModal,
  72. spinning: false,
  73. list: [],
  74. salesBillDetailSn: null,
  75. buyerSn: '',
  76. nowData: null,
  77. // 加载数据方法 必须为 Promise 对象
  78. loadData: parameter => {
  79. this.spinning = true
  80. return getPromoGoodsList(Object.assign(parameter, { salesBillDetailSn: this.nowData.salesBillDetailSn || undefined, buyerSn: this.buyerSn })).then(res => {
  81. let data
  82. if (res.status == 200) {
  83. data = res.data
  84. const no = (data.pageNo - 1) * data.pageSize
  85. for (var i = 0; i < data.list.length; i++) {
  86. data.list[i].no = no + i + 1
  87. data.list[i].qty = 1
  88. data.list[i].promotionSourceSn = this.nowData.salesBillDetailSn
  89. }
  90. }
  91. this.spinning = false
  92. return data
  93. })
  94. },
  95. rowSelectionInfo: null
  96. }
  97. },
  98. computed: {
  99. columns () {
  100. const arr = [
  101. { title: '产品编码', dataIndex: 'code', align: 'center', customRender: function (text) { return text || '--' } },
  102. { title: '产品名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' } },
  103. // { title: '原售价', dataIndex: 'productPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  104. // { title: '促销价', dataIndex: 'promoRuleGoods.goodsPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  105. { title: '数量', dataIndex: 'qty', scopedSlots: { customRender: 'salesNums' }, width: 100, align: 'center' },
  106. { title: '单位', dataIndex: 'unit', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  107. { title: '促销类型', dataIndex: 'promoRuleGoods.promoRuleTypeName', width: 100, align: 'center', customRender: function (text) { return text || '--' } }
  108. ]
  109. if (this.$hasPermissions('B_isShowCost')) { // 成本价权限
  110. arr.splice(2, 0, { title: '成本价', dataIndex: 'cost', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  111. }
  112. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  113. const ind = this.$hasPermissions('B_isShowCost') ? 3 : 2
  114. arr.splice(ind, 0, { title: '原售价', dataIndex: 'productPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  115. arr.splice(ind + 1, 0, { title: '促销价', dataIndex: 'promoRuleGoods.goodsPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  116. }
  117. return arr
  118. }
  119. },
  120. methods: {
  121. // 表格选中项
  122. rowSelectionFun (obj) {
  123. this.rowSelectionInfo = obj || null
  124. },
  125. // 选择产品
  126. handleSubmit () {
  127. const _this = this
  128. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  129. _this.$message.warning('请选择促销品!')
  130. return
  131. }
  132. const obj = []
  133. _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows.map(item => {
  134. obj.push({
  135. showCost: item.cost,
  136. price: item.promoRuleGoods.goodsPrice,
  137. origPrice: item.productPrice,
  138. packQty: item.packQty,
  139. productSn: item.productSn,
  140. promotionSourceSn: item.promotionSourceSn,
  141. promotionActivitySn: item.promoRuleGoods.promoActiveSn,
  142. promotionActivityName: item.promoRuleGoods.promoActiveName,
  143. promotionRules: item.promoRuleGoods.promoRuleSn,
  144. promoGoodsType: item.promoRuleGoods.promoGoodsType,
  145. qty: item.qty,
  146. promotableFlag: 0, // 可促销标记 有活动的传1,没活动的传0
  147. promotionFlag: 1 // 促销标记 正品传0,促销品传1
  148. })
  149. })
  150. _this.$emit('ok', obj)
  151. },
  152. cansel () {
  153. this.$emit('close')
  154. },
  155. getData (data, buyerSn) {
  156. const _this = this
  157. _this.buyerSn = buyerSn
  158. _this.nowData = data
  159. setTimeout(() => (
  160. _this.$refs.table.refresh(true)
  161. ), 300)
  162. }
  163. },
  164. watch: {
  165. // 父页面传过来的弹框状态
  166. openModal (newValue, oldValue) {
  167. this.isShow = newValue
  168. },
  169. // 重定义的弹框状态
  170. isShow (newValue, oldValue) {
  171. if (!newValue) {
  172. this.$refs.table.clearSelected() // 清空表格选中项
  173. this.$emit('close')
  174. }
  175. }
  176. }
  177. }
  178. </script>