detailModal.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <a-modal
  3. centered
  4. class="inventoryQueryDetail-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:10px">
  13. <div class="ftext" slot="message">
  14. 现有库存总数量(个):<strong>{{ currentStock&&(currentStock.currentQty || currentStock.currentQty==0) ? currentStock.currentQty : '--' }}</strong>;
  15. 现有库存总成本(¥):<strong>{{ currentStock&&(currentStock.putCost || currentStock.putCost==0) ? currentStock.putCost : '--' }}</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. {{ (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. 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: 'productCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  68. { title: '产品名称', dataIndex: 'productName', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  69. { title: '原厂编码', dataIndex: 'productOrigCode', 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. this.disabled = true
  80. return stockDetailList(Object.assign(parameter, { stockSn: this.itemId })).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. this.disabled = false
  87. // 总计
  88. this.getTotal(Object.assign(parameter, { stockSn: this.itemId }))
  89. return data
  90. })
  91. },
  92. currentStock: null
  93. }
  94. },
  95. methods: {
  96. // 合计
  97. getTotal (param) {
  98. stockDetailCount(param).then(res => {
  99. if (res.status == 200 && res.data) {
  100. this.currentStock = res.data
  101. } else {
  102. this.currentStock = null
  103. }
  104. })
  105. }
  106. },
  107. watch: {
  108. // 父页面传过来的弹框状态
  109. openModal (newValue, oldValue) {
  110. this.isShow = newValue
  111. },
  112. // 重定义的弹框状态
  113. isShow (newValue, oldValue) {
  114. if (!newValue) {
  115. this.$emit('close')
  116. }
  117. }
  118. }
  119. }
  120. </script>
  121. <style lang="less">
  122. .inventoryQueryDetail-modal{
  123. .btn-cont {
  124. text-align: center;
  125. margin: 5px 0 10px;
  126. }
  127. }
  128. </style>