chooseActive.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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: onChange,
  19. onSelect: onSelectChange,
  20. onSelectAll: onSelectAllChange,
  21. getCheckboxProps: record => ({
  22. props: {
  23. disabled: record.cost == undefined||record.cost==0||record.productPrice==0||record.productPrice==undefined, // Column configuration not to be checked
  24. }
  25. })
  26. }"
  27. :rowKey="(record) => record.id"
  28. :columns="columns"
  29. :data-source="list"
  30. :loading="loading"
  31. :scroll="{ x: 900, y: 350 }"
  32. bordered>
  33. <!-- 销售数量 -->
  34. <template slot="salesNums" slot-scope="text, record">
  35. <a-input-number
  36. size="small"
  37. :max="999999"
  38. :min="1"
  39. v-model="record.qty"
  40. :precision="0"
  41. :step="1"
  42. />
  43. </template>
  44. </a-table>
  45. <div style="display: flex;justify-content: center;padding: 10px 0;">
  46. <a-button
  47. size="large"
  48. type="primary"
  49. :loading="newLoading"
  50. class="button-primary"
  51. @click="handleSubmit"
  52. style="padding: 0 60px;">
  53. 确定
  54. </a-button>
  55. <a-button size="large" :loading="newLoading" style="padding: 0 60px;margin-left: 15px;font-size: 12px;" @click="cansel">
  56. 取消
  57. </a-button>
  58. </div>
  59. </a-card>
  60. </a-modal>
  61. </template>
  62. <script>
  63. import { STable, VSelect } from '@/components'
  64. import { getPromoGoodsList } from '@/api/salesDetail'
  65. export default {
  66. name: 'ChooseProduct',
  67. components: { STable, VSelect },
  68. props: {
  69. openModal: { // 弹框显示状态
  70. type: Boolean,
  71. default: false
  72. },
  73. buyerSn: {
  74. type: String,
  75. default: ''
  76. },
  77. newLoading: Boolean
  78. },
  79. data () {
  80. return {
  81. isShow: this.openModal,
  82. selectedRowKeys: [], // Check here to configure the default column
  83. selectedRows: [],
  84. loading: false,
  85. list: [],
  86. salesBillDetailSn: null
  87. }
  88. },
  89. computed: {
  90. columns () {
  91. const arr = [
  92. { title: '产品编码', dataIndex: 'code', align: 'center', customRender: function (text) { return text || '--' } },
  93. { title: '产品名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' } },
  94. { title: '原售价', dataIndex: 'productPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  95. { title: '促销价', dataIndex: 'promoRuleGoods.goodsPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  96. { title: '数量', dataIndex: 'qty', scopedSlots: { customRender: 'salesNums' }, width: 100, align: 'center' },
  97. { title: '单位', dataIndex: 'unit', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  98. { title: '促销类型', dataIndex: 'promoRuleGoods.promoRuleTypeName', width: 100, align: 'center', customRender: function (text) { return text || '--' } }
  99. ]
  100. if (this.$hasPermissions('B_isShowCost')) {
  101. arr.splice(2, 0, { title: '成本价', dataIndex: 'cost', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  102. }
  103. return arr
  104. }
  105. },
  106. methods: {
  107. getData (row) {
  108. this.loading = true
  109. this.salesBillDetailSn = row.salesBillDetailSn
  110. this.selectedRowKeys = []
  111. this.selectedRows = []
  112. getPromoGoodsList({ salesBillDetailSn: row.salesBillDetailSn, buyerSn: this.buyerSn }).then(res => {
  113. res.data.map(item => {
  114. item.qty = 1
  115. })
  116. this.list = res.data
  117. this.loading = false
  118. })
  119. },
  120. onChange (selectedRowKeys, selectedRows) {
  121. this.selectedRowKeys = selectedRowKeys
  122. },
  123. onSelectChange (record, selected, selectedRows, nativeEvent) {
  124. const _this = this
  125. if (selected) { // 选择
  126. this.selectedRows.push(record)
  127. } else { // 取消
  128. const arrId = []
  129. this.selectedRows.map((item, index) => {
  130. if (item.id == record.id) {
  131. arrId.push(index)
  132. }
  133. })
  134. arrId.map((item, index) => {
  135. _this.selectedRows = _this.selectedRows.slice(item, item + 1)
  136. })
  137. }
  138. },
  139. // 本页全选/取消全选
  140. onSelectAllChange (selected, selectedRows, changeRows) {
  141. const _this = this
  142. if (selected) { // 选择
  143. this.selectedRows = [...this.selectedRows, ...changeRows]
  144. } else { // 取消
  145. const arrId = []
  146. this.selectedRows.map((item, index) => {
  147. this.selectedRows.map((subItem, ind) => {
  148. if (item.id == subItem.id) {
  149. arrId.push(index)
  150. }
  151. })
  152. })
  153. arrId.map((item, index) => {
  154. _this.selectedRows = _this.selectedRows.slice(item, item + 1)
  155. })
  156. }
  157. },
  158. // 选择产品
  159. handleSubmit () {
  160. const _this = this
  161. if (_this.selectedRowKeys.length < 1) {
  162. _this.$message.warning('请选择促销品!')
  163. return
  164. }
  165. const obj = []
  166. _this.selectedRows.map(item => {
  167. obj.push({
  168. showCost: item.cost,
  169. price: item.promoRuleGoods.goodsPrice,
  170. origPrice: item.productPrice,
  171. packQty: item.packQty,
  172. productSn: item.productSn,
  173. promotionSourceSn: this.salesBillDetailSn,
  174. promotionActivitySn: item.promoRuleGoods.promoActiveSn,
  175. promotionActivityName: item.promoRuleGoods.promoActiveName,
  176. promotionRules: item.promoRuleGoods.promoRuleSn,
  177. promoGoodsType: item.promoRuleGoods.promoGoodsType,
  178. qty: item.qty,
  179. promotableFlag: 0, // 可促销标记 有活动的传1,没活动的传0
  180. promotionFlag: 1 // 促销标记 正品传0,促销品传1
  181. })
  182. })
  183. _this.$emit('ok', obj)
  184. },
  185. cansel () {
  186. this.$emit('close')
  187. }
  188. },
  189. watch: {
  190. // 父页面传过来的弹框状态
  191. openModal (newValue, oldValue) {
  192. this.isShow = newValue
  193. },
  194. // 重定义的弹框状态
  195. isShow (newValue, oldValue) {
  196. if (!newValue) {
  197. this.$emit('close')
  198. }
  199. }
  200. }
  201. }
  202. </script>