detailModal.vue 5.7 KB

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