queryPromotable.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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="{ x:1430, y: 300 }"
  11. :defaultLoadData="false"
  12. bordered>
  13. <!-- 产品名称 -->
  14. <template slot="productName" slot-scope="text, record">
  15. <span>{{ text }}</span>
  16. </template>
  17. <!-- 销售数量 -->
  18. <template slot="salesNums" slot-scope="text, record">
  19. <editable-cell
  20. size="small"
  21. :text="record.qty"
  22. :max="999999"
  23. :min="1"
  24. :precision="0"
  25. @change="onCellChange(record, $event)" />
  26. </template>
  27. <!-- 操作 -->
  28. <template slot="action" slot-scope="text, record">
  29. <a-button
  30. size="small"
  31. type="primary"
  32. :loading="delLoading"
  33. class="button-error"
  34. @click="handleDel(record)"
  35. >删除</a-button>
  36. </template>
  37. </s-table>
  38. </template>
  39. <script>
  40. import { salesDetailList } from '@/api/salesDetail'
  41. import { STable, VSelect } from '@/components'
  42. import EditableCell from '@/views/common/editInput.js'
  43. export default {
  44. name: 'Promotable',
  45. components: { STable, VSelect, EditableCell },
  46. props: {
  47. salesBillSn: {
  48. type: [Number, String],
  49. default: ''
  50. },
  51. delLoading: Boolean
  52. },
  53. data () {
  54. return {
  55. productForm: {
  56. salesBillSn: '',
  57. promotionFlag: 1
  58. },
  59. // 表头
  60. columns: [
  61. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  62. { title: '产品编码', dataIndex: 'productEntity.code', width: 220, align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
  63. { title: '产品名称', dataIndex: 'productEntity.name', scopedSlots: { customRender: 'productName' }, align: 'center' },
  64. { title: '成本价', dataIndex: 'showCost', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  65. { title: '原售价', dataIndex: 'origPrice', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  66. { title: '促销价', dataIndex: 'price', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  67. { title: '数量', dataIndex: 'qty', scopedSlots: { customRender: 'salesNums' }, width: 150, align: 'center' },
  68. { title: '单位', dataIndex: 'productEntity.unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  69. { title: '促销类型', dataIndex: 'promotionRulesName', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  70. { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
  71. ],
  72. // 加载数据方法 必须为 Promise 对象
  73. loadData: parameter => {
  74. this.productForm.salesBillSn = this.salesBillSn
  75. return salesDetailList(Object.assign(parameter, this.productForm)).then(res => {
  76. const data = res.data
  77. const no = (data.pageNo - 1) * data.pageSize
  78. for (var i = 0; i < data.list.length; i++) {
  79. data.list[i].no = no + i + 1
  80. }
  81. return data
  82. })
  83. }
  84. }
  85. },
  86. methods: {
  87. // 刷新当前页面
  88. resetCurForm () {
  89. this.$refs.table.refresh()
  90. },
  91. // 修改数量
  92. onCellChange (row, $event) {
  93. this.$emit('onCellChange', row, $event)
  94. },
  95. // 删除
  96. handleDel (row) {
  97. this.$emit('del', row)
  98. },
  99. getData () {
  100. this.$refs.table.refresh(true)
  101. }
  102. }
  103. }
  104. </script>
  105. <style>
  106. </style>