chooseActive.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. salesBillSn: null,
  76. buyerSn: '',
  77. nowData: null,
  78. // 加载数据方法 必须为 Promise 对象
  79. loadData: parameter => {
  80. this.spinning = true
  81. return getPromoGoodsList(Object.assign(parameter, { salesBillDetailSn: this.nowData.salesBillDetailSn || undefined, buyerSn: this.buyerSn, salesBillSn: this.salesBillSn })).then(res => {
  82. let data
  83. if (res.status == 200) {
  84. data = res.data
  85. const no = (data.pageNo - 1) * data.pageSize
  86. for (var i = 0; i < data.list.length; i++) {
  87. data.list[i].no = no + i + 1
  88. data.list[i].qty = 1
  89. data.list[i].promotionSourceSn = this.nowData.salesBillDetailSn
  90. }
  91. }
  92. this.spinning = false
  93. return data
  94. })
  95. },
  96. rowSelectionInfo: null
  97. }
  98. },
  99. computed: {
  100. columns () {
  101. const arr = [
  102. { title: '产品编码', dataIndex: 'code', align: 'center', customRender: function (text) { return text || '--' } },
  103. { title: '产品名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' } },
  104. // { title: '原售价', dataIndex: 'productPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  105. // { title: '促销价', dataIndex: 'promoRuleGoods.goodsPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  106. { title: '数量', dataIndex: 'qty', scopedSlots: { customRender: 'salesNums' }, width: 100, align: 'center' },
  107. { title: '单位', dataIndex: 'unit', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  108. { title: '促销类型', dataIndex: 'promoRuleGoods.promoRuleTypeName', width: 100, align: 'center', customRender: function (text) { return text || '--' } }
  109. ]
  110. if (this.$hasPermissions('B_salesEdit_costPrice')) { // 成本价权限
  111. arr.splice(2, 0, { title: '成本价', dataIndex: 'cost', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  112. }
  113. if (this.$hasPermissions('B_salesEdit_salesPrice')) { // 售价权限
  114. const ind = this.$hasPermissions('B_salesEdit_costPrice') ? 3 : 2
  115. arr.splice(ind, 0, { title: '原售价', dataIndex: 'productPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  116. arr.splice(ind + 1, 0, { title: '促销价', dataIndex: 'promoRuleGoods.goodsPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  117. }
  118. return arr
  119. }
  120. },
  121. methods: {
  122. // 表格选中项
  123. rowSelectionFun (obj) {
  124. this.rowSelectionInfo = obj || null
  125. },
  126. // 选择产品
  127. handleSubmit () {
  128. const _this = this
  129. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  130. _this.$message.warning('请选择促销品!')
  131. return
  132. }
  133. const obj = []
  134. _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows.map(item => {
  135. obj.push({
  136. showCost: item.cost,
  137. price: item.promoRuleGoods.goodsPrice,
  138. origPrice: item.productPrice,
  139. packQty: item.packQty,
  140. productSn: item.productSn,
  141. promotionSourceSn: item.promotionSourceSn,
  142. promotionActivitySn: item.promoRuleGoods.promoActiveSn,
  143. promotionActivityName: item.promoRuleGoods.promoActiveName,
  144. promotionRules: item.promoRuleGoods.promoRuleSn,
  145. promoGoodsType: item.promoRuleGoods.promoGoodsType,
  146. qty: item.qty,
  147. promotableFlag: 0, // 可促销标记 有活动的传1,没活动的传0
  148. promotionFlag: 1 // 促销标记 正品传0,促销品传1
  149. })
  150. })
  151. _this.$emit('ok', obj)
  152. },
  153. cansel () {
  154. this.$emit('close')
  155. },
  156. getData (data, buyerSn, salesBillSn) {
  157. const _this = this
  158. _this.buyerSn = buyerSn
  159. _this.nowData = data
  160. _this.salesBillSn = salesBillSn
  161. setTimeout(() => (
  162. _this.$refs.table.refresh(true)
  163. ), 300)
  164. }
  165. },
  166. watch: {
  167. // 父页面传过来的弹框状态
  168. openModal (newValue, oldValue) {
  169. this.isShow = newValue
  170. },
  171. // 重定义的弹框状态
  172. isShow (newValue, oldValue) {
  173. if (!newValue) {
  174. this.$refs.table.clearSelected() // 清空表格选中项
  175. this.$emit('close')
  176. }
  177. }
  178. }
  179. }
  180. </script>