123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- <template>
- <a-modal
- centered
- class="inventoryQueryDetail-modal"
- :footer="null"
- :maskClosable="false"
- title="库存详情"
- v-model="isShow"
- @cancel="isShow=false"
- width="80%">
- <!-- 合计 -->
- <a-alert type="info" style="margin-bottom:10px">
- <div class="ftext" slot="message">
- 可用库存总数量:<strong>{{ (currentStock&&(currentStock.currentStockQty || currentStock.currentStockQty==0)) ? currentStock.currentStockQty : '--' }}个</strong>;
- <span v-if="$hasPermissions('B_inventoryQuery_detail_costPrice')">可用库存总成本:<strong>{{ (currentStock&&(currentStock.currentStockCost || currentStock.currentStockCost==0)) ? toThousands(currentStock.currentStockCost) : '--' }}</strong>。</span>
- </div>
- </a-alert>
- <!-- 库存详情 -->
- <s-table
- v-if="openModal"
- class="sTable"
- ref="table"
- size="small"
- :rowKey="(record) => record.id"
- :columns="columns"
- :data="loadData"
- :scroll="{ y: 500 }"
- bordered>
- <template slot="currentQty" slot-scope="text, record">
- <span style="vertical-align: middle;margin-right:5px;"> {{ (record.currentQty ||record.currentQty==0)?record.currentQty:'--' }}</span>
- <a-tooltip placement="bottom" v-if="record.lockFlag==1" >
- <template slot="title">
- 采购入库的库存为锁定库存
- </template>
- <a-badge count="锁" v-if="record.lockFlag==1" :number-style="{ zoom:'80%' }"></a-badge>
- </a-tooltip>
- </template>
- </s-table>
- <div class="btn-cont">
- <a-button id="inventoryQueryDetail-detail-modal-back" @click="isShow = false">返回列表</a-button>
- </div>
- </a-modal>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { STable } from '@/components'
- import { stockDetailList, stockDetailCount } from '@/api/stock'
- export default {
- name: 'InventoryQueryDetailModal',
- mixins: [commonMixin],
- components: { STable },
- props: {
- openModal: { // 弹框显示状态
- type: Boolean,
- default: false
- },
- itemId: {
- type: [Number, String],
- default: ''
- }
- },
- data () {
- return {
- isShow: this.openModal, // 是否打开弹框
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- return stockDetailList(Object.assign(parameter, { stockSn: this.itemId })).then(res => {
- let data
- if (res.status == 200) {
- data = res.data
- const no = (data.pageNo - 1) * data.pageSize
- for (var i = 0; i < data.list.length; i++) {
- data.list[i].no = no + i + 1
- data.list[i].productOrigCode = data.list[i].productOrigCode.trim()
- }
- this.disabled = false
- // 总计
- this.getTotal(Object.assign(parameter, { stockSn: this.itemId }))
- }
- return data
- })
- },
- currentStock: { // 合计信息
- currentQty: '',
- putCost: ''
- }
- }
- },
- computed: {
- stockQty () { // 库存总数量 合计
- const currentStockQty = Number(this.currentStock.currentStockQty) || 0
- const freezeStockQty = Number(this.currentStock.freezeStockQty) || 0
- return currentStockQty + freezeStockQty
- },
- stockCost () { // 库存总成本 合计
- const currentStockCost = Number(this.currentStock.currentStockCost) || 0
- const freezeStockCost = Number(this.currentStock.freezeStockCost) || 0
- return ((currentStockCost * 1000 + freezeStockCost * 1000) / 1000).toFixed(2)
- },
- columns () {
- const _this = this
- const arr = [
- { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
- { title: '产品编码', dataIndex: 'productCode', width: '10%', align: 'left', customRender: function (text) { return text || '--' } },
- { title: '产品名称', dataIndex: 'productName', align: 'left', width: '22%', ellipsis: true, customRender: function (text) { return text || '--' } },
- { title: '原厂编码', dataIndex: 'productOrigCode', width: '10%', align: 'left', customRender: function (text) { return text || '--' } },
- { title: '入库时间', dataIndex: 'putTime', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '仓库', dataIndex: 'warehouseName', width: '10%', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
- { title: '仓位', dataIndex: 'warehouseLocationName', width: '10%', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
- { title: '入库类型', dataIndex: 'putBizTypeDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '库存数量', scopedSlots: { customRender: 'currentQty' }, dataIndex: 'currentQty', width: '6%', align: 'center' }
- ]
- if (this.$hasPermissions('B_inventoryQuery_detail_costPrice')) { // 成本价权限
- arr.splice(9, 0, { title: '成本单价', dataIndex: 'putCost', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
- }
- return arr
- }
- },
- methods: {
- // 合计
- getTotal (param) {
- stockDetailCount(param).then(res => {
- if (res.status == 200 && res.data) {
- this.currentStock = res.data
- } else {
- this.currentStock = { // 合计信息
- currentQty: '',
- putCost: ''
- }
- }
- })
- },
- resetPage () {
- this.currentStock = { // 合计信息
- currentQty: '',
- putCost: ''
- }
- this.$refs.table.clearTable()
- }
- },
- watch: {
- // 父页面传过来的弹框状态
- openModal (newValue, oldValue) {
- this.isShow = newValue
- },
- // 重定义的弹框状态
- isShow (newValue, oldValue) {
- if (!newValue) {
- this.resetPage()
- this.$emit('close')
- this.$store.state.app.curActionPermission = ''
- }
- }
- }
- }
- </script>
- <style lang="less">
- .inventoryQueryDetail-modal{
- .btn-cont {
- text-align: center;
- margin: 5px 0 10px;
- }
- }
- </style>
|