detailModal.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <a-modal
  3. centered
  4. class="chainStockReportDetail-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. :title="modalTit"
  8. v-model="isShow"
  9. @cancle="isShow=false"
  10. :width="960">
  11. <!-- 合计 -->
  12. <a-alert type="info" showIcon style="margin-bottom:15px">
  13. <div class="ftext" slot="message">
  14. 现有库存总数量(个):<strong> {{ (currentStock && currentStock.totalQty) || 0 }} </strong>;
  15. 现有库存总成本(¥):<strong> {{ (currentStock && currentStock.totalCost) || 0 }} </strong>。
  16. </div>
  17. </a-alert>
  18. <!-- 详情 -->
  19. <s-table
  20. v-if="openModal"
  21. class="sTable"
  22. ref="table"
  23. size="small"
  24. :rowKey="(record) => record.id"
  25. :columns="columns"
  26. :data="loadData"
  27. :scroll="{ x: 1580 }"
  28. bordered>
  29. <!-- 库存数量 -->
  30. <template slot="currentQty" slot-scope="text, record">
  31. {{ (Number(record.currentQty) + Number(record.freezeQty)) || 0 }}
  32. <span v-if="Number(record.freezeQty)">(冻结{{ record.freezeQty }})</span>
  33. </template>
  34. </s-table>
  35. <div class="btn-cont">
  36. <a-button id="chainStockReportDetail-detail-modal-back" @click="isShow = false">返回列表</a-button>
  37. </div>
  38. </a-modal>
  39. </template>
  40. <script>
  41. import { STable } from '@/components'
  42. import { reportStockDetailList, reportStockCount } from '@/api/reportStock'
  43. export default {
  44. name: 'InventoryQueryDetailModal',
  45. components: { STable },
  46. props: {
  47. openModal: { // 弹框显示状态
  48. type: Boolean,
  49. default: false
  50. },
  51. productSn: {
  52. type: [Number, String],
  53. default: ''
  54. }
  55. },
  56. computed: {
  57. modalTit () {
  58. return '详情'
  59. }
  60. },
  61. data () {
  62. return {
  63. isShow: this.openModal, // 是否打开弹框
  64. // 表头
  65. columns: [
  66. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  67. { title: '产品编码', dataIndex: 'productEntity.code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  68. { title: '产品名称', dataIndex: 'productEntity.name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  69. { title: '原厂编码', dataIndex: 'productEntity.origCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  70. { title: '入库时间', dataIndex: 'putTime', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  71. { title: '仓库', dataIndex: 'warehouseName', width: 140, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  72. { title: '仓位', dataIndex: 'warehouseLocationName', width: 140, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  73. { title: '入库类型', dataIndex: 'putBizTypeDictValue', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  74. { title: '库存数量', scopedSlots: { customRender: 'currentQty' }, width: 180, align: 'center' },
  75. { title: '成本单价', dataIndex: 'putCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  76. ],
  77. // 加载数据方法 必须为 Promise 对象
  78. loadData: parameter => {
  79. const params = Object.assign(parameter, { productSn: this.productSn })
  80. return reportStockDetailList(params).then(res => {
  81. const data = res.data
  82. const no = (data.pageNo - 1) * data.pageSize
  83. for (var i = 0; i < data.list.length; i++) {
  84. data.list[i].no = no + i + 1
  85. }
  86. // 总计
  87. this.getCount(params)
  88. return data
  89. })
  90. },
  91. currentStock: null
  92. }
  93. },
  94. methods: {
  95. // 合计
  96. getCount (param) {
  97. reportStockCount(param).then(res => {
  98. if (res.status == 200 && res.data) {
  99. this.currentStock = res.data
  100. } else {
  101. this.currentStock = null
  102. }
  103. })
  104. }
  105. },
  106. watch: {
  107. // 父页面传过来的弹框状态
  108. openModal (newValue, oldValue) {
  109. this.isShow = newValue
  110. },
  111. // 重定义的弹框状态
  112. isShow (newValue, oldValue) {
  113. if (!newValue) {
  114. this.$emit('close')
  115. }
  116. }
  117. }
  118. }
  119. </script>
  120. <style lang="less">
  121. .chainStockReportDetail-modal{
  122. .btn-cont {
  123. text-align: center;
  124. margin: 5px 0 10px;
  125. }
  126. }
  127. </style>