detailModal.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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>产品信息:
  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="{ x: 1180, 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 { STable } from '@/components'
  33. import { getOperationalPrecision } from '@/libs/tools.js'
  34. import { salesDetailPromoProductList } from '@/api/salesDetail'
  35. export default {
  36. name: 'OrderStatisticsDetailModal',
  37. components: { STable },
  38. props: {
  39. openModal: { // 弹框显示状态
  40. type: Boolean,
  41. default: false
  42. },
  43. itemSn: {
  44. type: [Number, String],
  45. default: ''
  46. },
  47. nowData: {
  48. type: Object,
  49. default: () => {
  50. return {}
  51. }
  52. }
  53. },
  54. data () {
  55. return {
  56. isShow: this.openModal, // 是否打开弹框
  57. // 表头
  58. columns: [
  59. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  60. { title: '采购单号', dataIndex: 'purchaseBillNo', align: 'center', customRender: function (text) { return text || '--' } },
  61. { title: '原价', dataIndex: 'origPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  62. { title: '促销价', dataIndex: 'price', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  63. { title: '数量', dataIndex: 'qty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  64. { title: '单位', dataIndex: 'productEntity.unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  65. { title: '原价小计', dataIndex: 'priceSubtotal', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  66. { title: '促销价小计', dataIndex: 'totalAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  67. { title: '节省金额小计', dataIndex: 'totalEconomizeAmount', width: 130, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  68. { title: '促销类型', dataIndex: 'promotionRulesName', width: 150, align: 'center', customRender: function (text) { return text || '--' } }
  69. ],
  70. // 加载数据方法 必须为 Promise 对象
  71. loadData: parameter => {
  72. return salesDetailPromoProductList(Object.assign(parameter, { productSn: this.itemSn, promotionFlag: 1 })).then(res => {
  73. const data = res.data
  74. const no = (data.pageNo - 1) * data.pageSize
  75. for (var i = 0; i < data.list.length; i++) {
  76. data.list[i].no = no + i + 1
  77. const origPrice = data.list[i].origPrice || 0
  78. const qty = data.list[i].qty || 0
  79. // 成本小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  80. data.list[i].priceSubtotal = getOperationalPrecision(origPrice, qty)
  81. }
  82. return data
  83. })
  84. }
  85. }
  86. },
  87. methods: {
  88. },
  89. watch: {
  90. // 父页面传过来的弹框状态
  91. openModal (newValue, oldValue) {
  92. this.isShow = newValue
  93. },
  94. // 重定义的弹框状态
  95. isShow (newValue, oldValue) {
  96. if (!newValue) {
  97. this.$emit('close')
  98. this.$refs.table.clearTable()
  99. }
  100. },
  101. itemSn (newValue, oldValue) {
  102. if (this.isShow && newValue) {
  103. const _this = this
  104. setTimeout(() => {
  105. _this.$refs.table.refresh(true)
  106. }, 300)
  107. }
  108. }
  109. }
  110. }
  111. </script>
  112. <style lang="less">
  113. .orderStatisticsDetail-modal{
  114. .ant-modal-body {
  115. padding: 40px 40px 24px;
  116. }
  117. .btn-cont {
  118. text-align: center;
  119. margin: 5px 0 10px;
  120. }
  121. }
  122. </style>