queryPromotable.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <!-- 已选配件列表 -->
  3. <s-table
  4. class="sTable"
  5. ref="table"
  6. size="small"
  7. :rowKey="(record) => record.id"
  8. :columns="columns"
  9. :data="loadData"
  10. :scroll="{ y: 300 }"
  11. :defaultLoadData="false"
  12. bordered>
  13. <!-- 销售数量 -->
  14. <template slot="salesNums" slot-scope="text, record">
  15. <a-input-number
  16. id="salesEdit-qty"
  17. size="small"
  18. v-model="record.qty"
  19. :precision="0"
  20. :min="1"
  21. :max="99999999"
  22. placeholder="请输入"
  23. @blur="e => onCellBlur(e.target.value, record)"
  24. style="width: 100%;" />
  25. </template>
  26. <!-- 操作 -->
  27. <template slot="action" slot-scope="text, record">
  28. <a-button
  29. size="small"
  30. type="link"
  31. :loading="delLoading"
  32. class="button-error"
  33. @click="handleDel(record)"
  34. >删除</a-button>
  35. </template>
  36. </s-table>
  37. </template>
  38. <script>
  39. import { commonMixin } from '@/utils/mixin'
  40. import { salesDetailList } from '@/api/salesDetail'
  41. import { STable, VSelect } from '@/components'
  42. export default {
  43. name: 'Promotable',
  44. mixins: [commonMixin],
  45. components: { STable, VSelect },
  46. props: {
  47. delLoading: Boolean
  48. },
  49. data () {
  50. return {
  51. productForm: {
  52. salesBillSn: '',
  53. promotionFlag: 1
  54. },
  55. salesBillSn: '',
  56. // 加载数据方法 必须为 Promise 对象
  57. loadData: parameter => {
  58. this.productForm.salesBillSn = this.salesBillSn
  59. return salesDetailList(Object.assign(parameter, this.productForm)).then(res => {
  60. let data
  61. if (res.status == 200) {
  62. data = res.data
  63. const no = (data.pageNo - 1) * data.pageSize
  64. for (var i = 0; i < data.list.length; i++) {
  65. data.list[i].no = no + i + 1
  66. data.list[i].qtyBackups = data.list[i].qty
  67. }
  68. }
  69. return data
  70. })
  71. }
  72. }
  73. },
  74. computed: {
  75. columns () {
  76. const arr = [
  77. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  78. { title: '产品编码', dataIndex: 'productEntity.code', width: '18%', align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
  79. { title: '产品名称', dataIndex: 'productEntity.name', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  80. // { title: '原售价', dataIndex: 'origPrice', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  81. // { title: '促销价', dataIndex: 'price', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  82. { title: '数量', dataIndex: 'qty', scopedSlots: { customRender: 'salesNums' }, width: '8%', align: 'center' },
  83. { title: '单位', dataIndex: 'productEntity.unit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  84. { title: '促销类型', dataIndex: 'promotionRulesName', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  85. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  86. ]
  87. if (this.$hasPermissions('B_salesEdit_costPrice')) { // 成本价权限
  88. arr.splice(3, 0, { title: '成本价', dataIndex: 'showCost', width: '8%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  89. }
  90. if (this.$hasPermissions('B_salesEdit_salesPrice')) { // 售价权限
  91. const ind = this.$hasPermissions('B_salesEdit_costPrice') ? 4 : 3
  92. arr.splice(ind, 0, { title: '原售价', dataIndex: 'origPrice', width: '8%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  93. arr.splice(ind + 1, 0, { title: '促销价', dataIndex: 'price', width: '8%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  94. }
  95. return arr
  96. }
  97. },
  98. methods: {
  99. // 刷新当前页面
  100. resetCurForm () {
  101. this.$refs.table.refresh()
  102. },
  103. // 修改数量
  104. onCellBlur (val, record) {
  105. this.$emit('onCellBlur', val, record)
  106. },
  107. // 删除
  108. handleDel (row) {
  109. this.$emit('del', row)
  110. },
  111. getData (salesBillSn) {
  112. this.salesBillSn = salesBillSn
  113. this.$refs.table.refresh(true)
  114. }
  115. }
  116. }
  117. </script>
  118. <style>
  119. </style>