detailModal.vue 5.1 KB

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