detailModal.vue 6.2 KB

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