detailModal.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <a-modal
  3. centered
  4. class="inventoryQueryDetail-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="库存详情"
  8. v-model="isShow"
  9. @cancle="isShow=false"
  10. :width="960">
  11. <!-- 合计 -->
  12. <a-alert type="info" style="margin-bottom:10px">
  13. <div class="ftext" slot="message">
  14. 可用库存总数量(个):<strong>{{ (currentStock&&(currentStock.currentStockQty || currentStock.currentStockQty==0)) ? currentStock.currentStockQty : '--' }}</strong>;
  15. <span v-if="$hasPermissions('B_isShowCost')">可用库存总成本(¥):<strong>{{ (currentStock&&(currentStock.currentStockCost || currentStock.currentStockCost==0)) ? currentStock.currentStockCost : '--' }}</strong>。</span>
  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: 1210, y: 500 }"
  28. bordered>
  29. </s-table>
  30. <div class="btn-cont">
  31. <a-button id="inventoryQueryDetail-detail-modal-back" @click="isShow = false">返回列表</a-button>
  32. </div>
  33. </a-modal>
  34. </template>
  35. <script>
  36. import { STable } from '@/components'
  37. import { stockDetailList, stockDetailCount } from '@/api/stock'
  38. export default {
  39. name: 'InventoryQueryDetailModal',
  40. components: { STable },
  41. props: {
  42. openModal: { // 弹框显示状态
  43. type: Boolean,
  44. default: false
  45. },
  46. itemId: {
  47. type: [Number, String],
  48. default: ''
  49. }
  50. },
  51. data () {
  52. return {
  53. isShow: this.openModal, // 是否打开弹框
  54. // 加载数据方法 必须为 Promise 对象
  55. loadData: parameter => {
  56. this.disabled = true
  57. return stockDetailList(Object.assign(parameter, { stockSn: this.itemId })).then(res => {
  58. const data = res.data
  59. const no = (data.pageNo - 1) * data.pageSize
  60. for (var i = 0; i < data.list.length; i++) {
  61. data.list[i].no = no + i + 1
  62. }
  63. this.disabled = false
  64. // 总计
  65. this.getTotal(Object.assign(parameter, { stockSn: this.itemId }))
  66. return data
  67. })
  68. },
  69. currentStock: { // 合计信息
  70. currentQty: '',
  71. putCost: ''
  72. }
  73. }
  74. },
  75. computed: {
  76. stockQty () { // 库存总数量 合计
  77. const currentStockQty = Number(this.currentStock.currentStockQty) || 0
  78. const freezeStockQty = Number(this.currentStock.freezeStockQty) || 0
  79. return currentStockQty + freezeStockQty
  80. },
  81. stockCost () { // 库存总成本 合计
  82. const currentStockCost = Number(this.currentStock.currentStockCost) || 0
  83. const freezeStockCost = Number(this.currentStock.freezeStockCost) || 0
  84. return ((currentStockCost * 1000 + freezeStockCost * 1000) / 1000).toFixed(2)
  85. },
  86. columns () {
  87. const arr = [
  88. { title: '序号', dataIndex: 'no', width: 50, align: 'center' },
  89. { title: '产品编码', dataIndex: 'productCode', width: 180, align: 'center', customRender: function (text) { return text || '--' } },
  90. { title: '产品名称', dataIndex: 'productName', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  91. { title: '原厂编码', dataIndex: 'productOrigCode', width: 180, align: 'center', customRender: function (text) { return text || '--' } },
  92. { title: '入库时间', dataIndex: 'putTime', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  93. { title: '仓库', dataIndex: 'warehouseName', width: 100, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  94. { title: '仓位', dataIndex: 'warehouseLocationName', width: 100, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  95. { title: '入库类型', dataIndex: 'putBizTypeDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  96. { title: '库存数量', dataIndex: 'currentQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  97. ]
  98. if (this.$hasPermissions('B_isShowCost')) {
  99. arr.splice(9, 0, { title: '成本单价', dataIndex: 'putCost', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  100. }
  101. return arr
  102. }
  103. },
  104. methods: {
  105. // 合计
  106. getTotal (param) {
  107. stockDetailCount(param).then(res => {
  108. if (res.status == 200 && res.data) {
  109. this.currentStock = res.data
  110. } else {
  111. this.currentStock = { // 合计信息
  112. currentQty: '',
  113. putCost: ''
  114. }
  115. }
  116. })
  117. }
  118. },
  119. watch: {
  120. // 父页面传过来的弹框状态
  121. openModal (newValue, oldValue) {
  122. this.isShow = newValue
  123. },
  124. // 重定义的弹框状态
  125. isShow (newValue, oldValue) {
  126. if (!newValue) {
  127. this.$emit('close')
  128. }
  129. }
  130. }
  131. }
  132. </script>
  133. <style lang="less">
  134. .inventoryQueryDetail-modal{
  135. .btn-cont {
  136. text-align: center;
  137. margin: 5px 0 10px;
  138. }
  139. }
  140. </style>