detailModal.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <a-modal
  3. centered
  4. class="orderStatisticsDetail-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="促销品明细"
  8. v-model="isShow"
  9. @cancle="isShow=false"
  10. :width="960">
  11. <div>
  12. <p>销售单号:{{ nowData ? (nowData.salesBillNo || '--') : '--' }}</p>
  13. <!-- 列表 -->
  14. <s-table
  15. class="sTable"
  16. ref="table"
  17. size="small"
  18. :rowKey="(record) => record.id"
  19. :columns="columns"
  20. :data="loadData"
  21. :defaultLoadData="false"
  22. :scroll="{ y: 400 }"
  23. bordered>
  24. </s-table>
  25. <div class="btn-cont"><a-button id="orderStatisticsDetail-back" @click="isShow = false">返回列表</a-button></div>
  26. </div>
  27. </a-modal>
  28. </template>
  29. <script>
  30. import { STable } from '@/components'
  31. import { getOperationalPrecision } from '@/libs/tools.js'
  32. import { salesDetailList } from '@/api/salesDetail'
  33. export default {
  34. name: 'OrderStatisticsDetailModal',
  35. components: { STable },
  36. props: {
  37. openModal: { // 弹框显示状态
  38. type: Boolean,
  39. default: false
  40. },
  41. itemSn: {
  42. type: [Number, String],
  43. default: ''
  44. },
  45. nowData: {
  46. type: Object,
  47. default: () => {
  48. return {}
  49. }
  50. }
  51. },
  52. data () {
  53. return {
  54. isShow: this.openModal, // 是否打开弹框
  55. // 加载数据方法 必须为 Promise 对象
  56. loadData: parameter => {
  57. return salesDetailList(Object.assign(parameter, { salesBillSn: this.itemSn, promotionFlag: 1 })).then(res => {
  58. let data
  59. if (res.status == 200) {
  60. data = res.data
  61. const no = (data.pageNo - 1) * data.pageSize
  62. for (var i = 0; i < data.list.length; i++) {
  63. data.list[i].no = no + i + 1
  64. const origPrice = data.list[i].origPrice || 0
  65. const qty = data.list[i].qty || 0
  66. // 成本小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  67. data.list[i].priceSubtotal = getOperationalPrecision(origPrice, qty)
  68. }
  69. }
  70. return data
  71. })
  72. }
  73. }
  74. },
  75. computed: {
  76. columns () {
  77. const arr = [
  78. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  79. { title: '产品编码', dataIndex: 'productEntity.code', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  80. { title: '产品名称', dataIndex: 'productEntity.name', width: '30%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  81. // { title: '原价', dataIndex: 'origPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  82. // { title: '促销价', dataIndex: 'price', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  83. { title: '数量', dataIndex: 'qty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  84. { title: '单位', dataIndex: 'productEntity.unit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  85. // { title: '原价小计', dataIndex: 'priceSubtotal', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  86. // { title: '促销价小计', dataIndex: 'totalAmount', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  87. // { title: '节省金额小计', dataIndex: 'totalEconomizeAmount', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  88. { title: '促销类型', dataIndex: 'promotionRulesName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } }
  89. ]
  90. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  91. arr.splice(3, 0, { title: '原价', dataIndex: 'origPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  92. arr.splice(4, 0, { title: '促销价', dataIndex: 'price', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  93. arr.splice(7, 0, { title: '原价小计', dataIndex: 'priceSubtotal', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  94. arr.splice(8, 0, { title: '促销价小计', dataIndex: 'totalAmount', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  95. arr.splice(9, 0, { title: '节省金额小计', dataIndex: 'totalEconomizeAmount', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  96. }
  97. return arr
  98. }
  99. },
  100. methods: {
  101. },
  102. watch: {
  103. // 父页面传过来的弹框状态
  104. openModal (newValue, oldValue) {
  105. this.isShow = newValue
  106. },
  107. // 重定义的弹框状态
  108. isShow (newValue, oldValue) {
  109. if (!newValue) {
  110. this.$emit('close')
  111. this.$refs.table.clearTable()
  112. }
  113. },
  114. itemSn (newValue, oldValue) {
  115. if (this.isShow && newValue) {
  116. const _this = this
  117. setTimeout(() => {
  118. _this.$refs.table.refresh(true)
  119. }, 300)
  120. }
  121. }
  122. }
  123. }
  124. </script>
  125. <style lang="less">
  126. .orderStatisticsDetail-modal{
  127. .ant-modal-body {
  128. padding: 40px 40px 24px;
  129. }
  130. .btn-cont {
  131. text-align: center;
  132. margin: 5px 0 10px;
  133. }
  134. }
  135. </style>