detailModal.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. @cancel="isShow=false"
  10. width="75%">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <!-- 合计 -->
  13. <a-alert type="info" style="margin-bottom:10px">
  14. <div class="ftext" slot="message">
  15. 可用库存总数量:<strong>{{ currentStock&&(currentStock.currentStockQty || currentStock.currentStockQty==0) ? currentStock.currentStockQty : '--' }}个</strong>;
  16. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  17. 可用库存总成本:<strong>{{ currentStock&&(currentStock.currentStockCost || currentStock.currentStockCost==0) ? toThousands(currentStock.currentStockCost) : '--' }}</strong>;
  18. </div>
  19. 冻结库存总数量:<strong>{{ currentStock&&(currentStock.freezeQty || currentStock.freezeQty==0) ? currentStock.freezeQty : '--' }}个</strong>;
  20. <div style="display: inline-block;" v-if="$hasPermissions('M_ShowAllCost')">
  21. 冻结库存总成本:<strong>{{ currentStock&&(currentStock.freezeCost || currentStock.freezeCost==0) ? toThousands(currentStock.freezeCost) : '--' }}</strong>。
  22. </div>
  23. </div>
  24. </a-alert>
  25. <!-- 库存详情 -->
  26. <s-table
  27. v-if="openModal"
  28. class="sTable"
  29. ref="table"
  30. size="small"
  31. :rowKey="(record) => record.id"
  32. :columns="columns"
  33. :data="loadData"
  34. :scroll="{ y: 500 }"
  35. bordered>
  36. <!-- 操作 -->
  37. <template slot="putCost" slot-scope="text, record">
  38. <!-- <a-input-number
  39. :id="'salesEdit-price-'+record.productSn"
  40. size="small"
  41. v-model="record.putCost"
  42. :precision="2"
  43. :min="0"
  44. :max="999999"
  45. placeholder="请输入"
  46. @blur="e => priceBlur(e.target.value, record)"
  47. style="width: 100%;" /> -->
  48. {{ record.putCost }}
  49. </template>
  50. </s-table>
  51. <div class="btn-cont">
  52. <a-button id="inventoryQueryDetail-detail-modal-back" @click="isShow = false">返回列表</a-button>
  53. </div>
  54. </a-spin>
  55. </a-modal>
  56. </template>
  57. <script>
  58. import { commonMixin } from '@/utils/mixin'
  59. import { STable } from '@/components'
  60. import { stockDetailList, stockByProductSn } from '@/api/stock'
  61. export default {
  62. name: 'InventoryQueryDetailModal',
  63. components: { STable },
  64. mixins: [commonMixin],
  65. props: {
  66. openModal: { // 弹框显示状态
  67. type: Boolean,
  68. default: false
  69. },
  70. nowData: {// 当前选中产品信息
  71. type: Object,
  72. default: () => {
  73. return {}
  74. }
  75. }
  76. },
  77. computed: {
  78. // 弹框标题
  79. modalTit () {
  80. return '库存详情'
  81. },
  82. // 列
  83. columns () {
  84. const _this = this
  85. const arr = [
  86. { title: '序号', dataIndex: 'no', width: 40, align: 'center' },
  87. { title: '产品编码', dataIndex: 'productCode', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  88. { title: '产品名称', dataIndex: 'productName', width: 150, align: 'left', ellipsis: true, customRender: function (text) { return text || '--' } },
  89. { title: '原厂编码', dataIndex: 'productOrigCode', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  90. { title: '入库时间', dataIndex: 'putTime', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  91. { title: '仓库', dataIndex: 'warehouseName', width: 100, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  92. { title: '仓位', dataIndex: 'warehouseLocationName', width: 100, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  93. { title: '入库类型', dataIndex: 'putBizTypeDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  94. { title: '可用库存数量', dataIndex: 'currentQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  95. { title: '冻结库存数量', dataIndex: 'freezeQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  96. ]
  97. if (this.$hasPermissions('M_ShowAllCost')) {
  98. // arr.push({ title: '成本单价', dataIndex: 'putCost', width: 100, align: 'right', scopedSlots: { customRender: 'putCost' } })
  99. arr.push({ title: '成本单价', dataIndex: 'putCost', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  100. }
  101. return arr
  102. }
  103. },
  104. data () {
  105. return {
  106. spinning: false,
  107. isShow: this.openModal, // 是否打开弹框
  108. // 加载数据方法 必须为 Promise 对象
  109. loadData: parameter => {
  110. this.disabled = true
  111. this.spinning = true
  112. const queryParams = Object.assign(parameter, { stockSn: this.nowData && this.nowData.stockSn || '', existStockFlag: '1' })
  113. return stockDetailList(queryParams).then(res => {
  114. let data
  115. if (res.status == 200) {
  116. data = res.data
  117. const no = (data.pageNo - 1) * data.pageSize
  118. for (var i = 0; i < data.list.length; i++) {
  119. data.list[i].no = no + i + 1
  120. data.list[i].putCostBackups = data.list[i].putCost
  121. }
  122. this.disabled = false
  123. // 总计
  124. this.getTotal(queryParams)
  125. }
  126. this.spinning = false
  127. return data
  128. })
  129. },
  130. currentStock: null // 合计数据
  131. }
  132. },
  133. methods: {
  134. // 合计
  135. getTotal (param) {
  136. stockByProductSn({ productSn: this.nowData && this.nowData.productSn || '' }).then(res => {
  137. if (res.status == 200 && res.data) {
  138. this.currentStock = res.data
  139. } else {
  140. this.currentStock = null
  141. }
  142. })
  143. },
  144. // 已选产品 售价 input 输入框 blur
  145. priceBlur (val, record) {
  146. this.dataSource = record || []
  147. // 光标移出,值发生改变再调用编辑接口
  148. if (val && val != record.putCostBackups) {
  149. this.spinning = true
  150. salesDetailUpdatePrice({
  151. id: record.id,
  152. newConst: record.putCost,
  153. putCost: record.putCostBackups
  154. }).then(res => {
  155. if (res.status == 200) {
  156. this.$message.info(res.message)
  157. } else {
  158. record.putCost = record.putCostBackups
  159. }
  160. this.spinning = false
  161. })
  162. } else {
  163. record.putCost = record.putCostBackups
  164. }
  165. }
  166. },
  167. watch: {
  168. // 父页面传过来的弹框状态
  169. openModal (newValue, oldValue) {
  170. this.isShow = newValue
  171. },
  172. // 重定义的弹框状态
  173. isShow (newValue, oldValue) {
  174. if (!newValue) {
  175. this.$emit('close')
  176. this.currentStock = null
  177. this.$refs.table.clearTable()
  178. }
  179. }
  180. }
  181. }
  182. </script>
  183. <style lang="less">
  184. .inventoryQueryDetail-modal{
  185. .ant-input-number-sm input{
  186. text-align:right;
  187. }
  188. .btn-cont {
  189. text-align: center;
  190. margin: 5px 0 10px;
  191. }
  192. }
  193. </style>