123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- <template>
- <div class="inventoryQueryWarehouseDetail-wrap">
- <a-page-header :ghost="false" :backIcon="false" class="inventoryQueryWarehouseDetail-back">
- <!-- 自定义的二级文字标题 -->
- <template slot="subTitle">
- <a id="inventoryQueryWarehouseDetail-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
- </template>
- </a-page-header>
- <a-card size="small" :bordered="false" class="inventoryQueryWarehouseDetail-cont">
- <!-- 搜索条件 -->
- <div class="table-page-search-wrapper">
- <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
- <a-row :gutter="15">
- <a-col :md="6" :sm="24">
- <a-form-item label="变动类型">
- <v-select
- v-model="queryParam.flowType"
- ref="flowType"
- id="warehousingAuditList-flowType"
- code="STOCK_FLOW_TYPE"
- placeholder="请选择变动类型"
- allowClear></v-select>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="单据类型">
- <v-select
- v-model="queryParam.bizType"
- ref="bizType"
- id="inventoryQueryWarehouseDetail-bizType"
- code="STOCK_FLOW_BIZ_TYPE"
- placeholder="请选择单据类型"
- allowClear></v-select>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="仓库">
- <a-select id="inventoryQueryWarehouseDetail-warehouseSn" placeholder="请选择仓库" v-model="queryParam.warehouseSn" >
- <a-select-option v-for="item in warehouseList" :key="item.warehouseSn" :value="item.warehouseSn">{{ item.name }}</a-select-option>
- </a-select>
- </a-form-item>
- </a-col>
- <template v-if="advanced">
- <a-col :md="6" :sm="24">
- <a-form-item label="单据审核时间">
- <a-range-picker
- style="width:100%"
- id="inventoryQueryWarehouseDetail-createDate"
- :disabledDate="disabledDate"
- v-model="createDate"
- :format="dateFormat"
- :placeholder="['开始时间', '结束时间']" />
- </a-form-item>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="单位名称">
- <a-input id="inventoryQueryWarehouseDetail-unitName" v-model.trim="queryParam.unitName" allowClear placeholder="请输入单位名称"/>
- </a-form-item>
- </a-col>
- </template>
- <a-col :md="6" :sm="24">
- <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="inventoryQueryWarehouseDetail-refresh">查询</a-button>
- <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="inventoryQueryWarehouseDetail-reset">重置</a-button>
- <a @click="advanced=!advanced" style="margin-left: 8px">
- {{ advanced ? '收起' : '展开' }}
- <a-icon :type="advanced ? 'up' : 'down'"/>
- </a>
- </a-col>
- </a-row>
- </a-form>
- </div>
- <!-- 合计 -->
- <a-alert type="info" showIcon style="margin-bottom:15px">
- <div class="ftext" slot="message">当前库存总数量(个):<strong>{{ productTotal.stockQty }}</strong>;当前库存总成本(¥):<strong>{{ productTotal.stockCost }}</strong>。</div>
- </a-alert>
- <!-- 列表 -->
- <s-table
- class="sTable"
- ref="table"
- size="default"
- :rowKey="(record) => record.id"
- :columns="columns"
- :data="loadData"
- :scroll="{ x: 1760 }"
- bordered>
- <!-- 数量 -->
- <template slot="qty" slot-scope="text, record">
- <span :class="record.flowType=='PUT' ? 'green':'red'">{{ record.flowType=='PUT' ? '+':'-' }}{{ record.qty }}</span>
- </template>
- </s-table>
- </a-card>
- </div>
- </template>
- <script>
- import moment from 'moment'
- import { STable, VSelect } from '@/components'
- import { stockFlowList } from '@/api/stockFlow'
- import { stockByProductSn } from '@/api/stock'
- import { warehouseAllList } from '@/api/warehouse'
- export default {
- components: { STable, VSelect },
- data () {
- return {
- advanced: false, // 高级搜索 展开/关闭
- queryParam: { // 查询条件
- bizType: undefined,
- flowType: undefined,
- unitName: '',
- warehouseSn: undefined
- },
- exportLoading: false, // 导出loading
- disabled: false, // 查询、重置按钮是否可操作
- createDate: [],
- dateFormat: 'YYYY-MM-DD',
- columns: [
- { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
- { title: '产品编码', dataIndex: 'product.code', width: 140, align: 'center', fixed: 'left', customRender: function (text) { return text || '--' } },
- { title: '产品名称', dataIndex: 'product.name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
- { title: '原厂编码', dataIndex: 'product.origCode', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '入库批次时间', dataIndex: 'stockBatchNo', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '单据类型', dataIndex: 'bizTypeDictValue', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '单据审核时间', dataIndex: 'auditTime', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '单位名称', dataIndex: 'unitName', width: 200, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
- { title: '仓库', dataIndex: 'warehouseName', width: 140, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
- { title: '仓位', dataIndex: 'warehouseLocationName', width: 140, align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
- { title: '数量', scopedSlots: { customRender: 'qty' }, width: 100, align: 'center' },
- { title: '总成本', dataIndex: 'totalCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '总售价', dataIndex: 'totalPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
- ],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- // 入库时间
- if (this.createDate && this.createDate.length > 0) {
- this.queryParam.beginDate = moment(this.createDate[0]).format(this.dateFormat)
- this.queryParam.endDate = moment(this.createDate[1]).format(this.dateFormat)
- } else {
- this.queryParam.beginDate = undefined
- this.queryParam.endDate = undefined
- }
- const params = Object.assign(parameter, this.queryParam, { productSn: this.$route.params.sn })
- return stockFlowList(params).then(res => {
- const 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
- if (data.list[i].flowType == 'PUT') {
- data.list[i].qty = data.list[i].putQty
- } else if (data.list[i].flowType == 'OUT') {
- data.list[i].qty = data.list[i].outQty
- }
- }
- this.disabled = false
- this.getTotal(params)
- return data
- })
- },
- warehouseList: [], // 仓库 下拉数据
- productTotal: {
- stockQty: 0,
- stockCost: 0
- } // 合计
- }
- },
- methods: {
- // 不可选日期
- disabledDate (date, dateStrings) {
- return date && date.valueOf() > Date.now()
- },
- // 合计
- getTotal (param) {
- stockByProductSn(param).then(res => {
- if (res.status == 200 && res.data) {
- this.productTotal = {
- stockQty: (Number(res.data.currentStockQty) + Number(res.data.freezeQty)) || 0,
- stockCost: (Number(res.data.currentStockCost) + Number(res.data.freezeCost)) || 0
- }
- } else {
- this.productTotal = {
- stockQty: 0,
- stockCost: 0
- }
- }
- })
- },
- // 重置
- resetSearchForm () {
- this.queryParam.bizType = undefined
- this.queryParam.flowType = undefined
- this.queryParam.unitName = ''
- this.queryParam.warehouseSn = undefined
- this.createDate = []
- this.$refs.table.refresh(true)
- },
- // 返回列表
- handleBack () {
- this.$router.push({ path: '/inventoryManagement/inventoryQuery/list' })
- },
- // 仓库下拉数据
- getWarehouseList (type) {
- warehouseAllList({}).then(res => {
- if (res.status == 200) {
- this.warehouseList = res.data
- } else {
- this.warehouseList = []
- }
- })
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {
- vm.getWarehouseList()
- })
- }
- }
- </script>
- <style lang="less">
- .inventoryQueryWarehouseDetail-wrap{
- .inventoryQueryWarehouseDetail-back{
- margin-bottom: 15px;
- }
- .inventoryQueryWarehouseDetail-cont{
- margin-bottom: 15px;
- }
- .green{
- color: #19be6b;
- }
- .red{
- color: #ed1c24;
- }
- }
- </style>
|