123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327 |
- <template>
- <div class="inventoryQueryWarehouseDetail-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <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 ref="tableSearch" class="table-page-search-wrapper">
- <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
- <a-row :gutter="15">
- <a-col :md="4" :sm="24">
- <a-form-item label="变动类型">
- <v-select
- v-model="queryParam.flowType"
- ref="flowType"
- id="inventoryQueryWarehouseDetail-flowType"
- code="STOCK_FLOW_TYPE"
- placeholder="请选择变动类型"
- allowClear></v-select>
- </a-form-item>
- </a-col>
- <a-col :md="4" :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="4" :sm="24">
- <a-form-item label="仓库">
- <a-select id="inventoryQueryWarehouseDetail-warehouseSn" allowClear 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>
- <a-col :md="6" :sm="24">
- <a-form-item label="单据审核时间">
- <rangeDate ref="rangeDate" @change="dateChange" />
- </a-form-item>
- </a-col>
- <template v-if="advanced">
- <a-col :md="6" :sm="24">
- <a-form-item label="关联单号">
- <a-input id="inventoryQueryWarehouseDetail-bizNo" v-model.trim="queryParam.bizNo" allowClear placeholder="请输入关联单号"/>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="下推单号">
- <a-input id="inventoryQueryWarehouseDetail-bizSubNo" v-model.trim="queryParam.bizSubNo" allowClear placeholder="请输入下推单号"/>
- </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>
- <a-col :md="6" :sm="24">
- <a-form-item label="出入库状态">
- <v-select
- v-model="queryParam.state"
- ref="state"
- id="inventoryQueryWarehouseDetail-state"
- code="STOCK_FLOW_STATE"
- placeholder="请选择出入库状态"
- allowClear></v-select>
- </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: 5px" @click="resetSearchForm" :disabled="disabled" id="inventoryQueryWarehouseDetail-reset">重置</a-button>
- <a-button
- type="primary"
- style="margin-left: 5px"
- class="button-warning"
- v-if="$hasPermissions('B_inventoryQuery_rkDetail_export')"
- @click="handleExcel"
- :disabled="disabled"
- :loading="exportLoading"
- id="inventoryQueryList-export">导出</a-button>
- <a @click="advanced=!advanced" style="margin-left: 5px">
- {{ advanced ? '收起' : '展开' }}
- <a-icon :type="advanced ? 'up' : 'down'"/>
- </a>
- </a-col>
- </a-row>
- </a-form>
- </div>
- <!-- 合计 -->
- <a-alert type="info" style="margin-bottom:10px">
- <div class="ftext" slot="message">
- 当前库存总数量(个):<strong>{{ (productTotal&&(productTotal.totalQty || productTotal.totalQty==0)) ? productTotal.totalQty : '--' }}</strong>;
- 入库总数量(个):<strong>{{ (productTotal&&(productTotal.totalPutQty || productTotal.totalPutQty==0)) ? productTotal.totalPutQty : '--' }}</strong>;
- 出库总数量(个):<strong>{{ (productTotal&&(productTotal.totalOutQty || productTotal.totalOutQty==0)) ? productTotal.totalOutQty : '--' }}</strong>;
- <span v-if="$hasPermissions('B_isShowCost')">当前库存总成本(¥):<strong>{{ (productTotal&&(productTotal.totalCost || productTotal.totalCost==0)) ? productTotal.totalCost : '--' }}</strong>。</span>
- </div>
- </a-alert>
- <!-- 列表 -->
- <s-table
- class="sTable fixPagination"
- ref="table"
- :style="{ height: tableHeight+84.5+'px' }"
- size="small"
- :rowKey="(record) => record.id"
- :columns="columns"
- :data="loadData"
- :scroll="{ y: tableHeight }"
- :defaultLoadData="false"
- bordered>
- <!-- 数量 -->
- <template slot="qty" slot-scope="text, record">
- <p :class="record.flowType=='PUT' ? 'green':'red'" style="margin: 0;">
- <span v-if="record.qty!=0">{{ record.flowType=='PUT' ? '+':'-' }}</span>
- {{ record.qty }}
- </p>
- </template>
- </s-table>
- </a-card>
- </a-spin>
- </div>
- </template>
- <script>
- import { STable, VSelect } from '@/components'
- import rangeDate from '@/views/common/rangeDate.vue'
- import { hdExportExcel } from '@/libs/exportExcel'
- import { stockFlowCount, stockFlowList, stockFlowExport } from '@/api/stock'
- import { warehouseAllList } from '@/api/warehouse'
- export default {
- components: { STable, VSelect, rangeDate },
- data () {
- return {
- spinning: false,
- advanced: false, // 高级搜索 展开/关闭
- tableHeight: 0,
- queryParam: { // 查询条件
- beginDate: '',
- endDate: '',
- bizType: undefined,
- flowType: undefined,
- unitName: '',
- bizNo: '',
- bizSubNo: '',
- warehouseSn: undefined,
- state: undefined
- },
- disabled: false, // 查询、重置按钮是否可操作
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- this.spinning = true
- const params = Object.assign(parameter, this.queryParam, { productSn: this.$route.params.sn })
- return stockFlowList(params).then(res => {
- let data
- if (res.status == 200) {
- data = res.data
- this.getTotal(params)
- 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.spinning = false
- return data
- })
- },
- exportLoading: false,
- warehouseList: [], // 仓库 下拉数据
- productTotal: null // 合计
- }
- },
- computed: {
- columns () {
- const arr = [
- { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
- { title: '产品编码', dataIndex: 'productCode', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '产品名称', dataIndex: 'productName', width: '14%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '原厂编码', dataIndex: 'productOrigCode', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '批次号', dataIndex: 'stockBatchNo', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '单据类型', dataIndex: 'bizTypeDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '关联单号', dataIndex: 'bizNo', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '下推单号', dataIndex: 'bizSubNo', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '单据审核时间', dataIndex: 'auditTime', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '单位名称', dataIndex: 'unitName', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '仓库', dataIndex: 'warehouseName', width: '4%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '仓位', dataIndex: 'warehouseLocationName', width: '4%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '数量', scopedSlots: { customRender: 'qty' }, width: '4%', align: 'center' },
- { title: '出入库状态', dataIndex: 'stateDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } }
- // { title: '总成本', dataIndex: 'totalCost', width: '4%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- // { title: '总售价', dataIndex: 'totalPrice', width: '4%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
- ]
- if (this.$hasPermissions('B_isShowCost')) { // 成本价权限
- arr.splice(13, 0, { title: '总成本', dataIndex: 'totalCost', width: '4%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
- }
- if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
- arr.splice(arr.length, 0, { title: '总售价', dataIndex: 'totalPrice', width: '4%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
- }
- return arr
- }
- },
- methods: {
- // 创建时间 change
- dateChange (date) {
- this.queryParam.beginDate = date[0]
- this.queryParam.endDate = date[1]
- },
- // 合计
- getTotal (param) {
- stockFlowCount(param).then(res => {
- if (res.status == 200 && res.data) {
- this.productTotal = res.data
- } else {
- this.productTotal = null
- }
- })
- },
- // 重置
- resetSearchForm () {
- this.$refs.rangeDate.resetDate()
- this.queryParam.beginDate = ''
- this.queryParam.endDate = ''
- this.queryParam.bizType = undefined
- this.queryParam.flowType = undefined
- this.queryParam.unitName = ''
- this.queryParam.bizSubNo = ''
- this.queryParam.bizNo = ''
- this.queryParam.warehouseSn = undefined
- this.queryParam.state = undefined
- this.$refs.table.refresh(true)
- },
- // 导出
- handleExcel () {
- const _this = this
- const params = Object.assign(this.queryParam, { productSn: this.$route.params.sn })
- this.exportLoading = true
- this.spinning = true
- hdExportExcel(stockFlowExport, params, '出入库明细', function () {
- _this.exportLoading = false
- _this.spinning = false
- })
- },
- // 返回列表
- handleBack () {
- this.$router.push({ path: '/inventoryManagement/inventoryQuery/list', query: { closeLastOldTab: true } })
- },
- // 仓库下拉数据
- getWarehouseList (type) {
- warehouseAllList({}).then(res => {
- if (res.status == 200) {
- this.warehouseList = res.data
- } else {
- this.warehouseList = []
- }
- })
- },
- pageInit () {
- const _this = this
- this.$nextTick(() => { // 页面渲染完成后的回调
- _this.setTableH()
- })
- this.getWarehouseList()
- },
- setTableH () {
- const tableSearchH = this.$refs.tableSearch.offsetHeight
- this.tableHeight = window.innerHeight - tableSearchH - 230 - 62
- }
- },
- watch: {
- advanced (newValue, oldValue) {
- const _this = this
- this.$nextTick(() => { // 页面渲染完成后的回调
- _this.setTableH()
- })
- },
- '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
- this.setTableH()
- }
- },
- mounted () {
- if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
- this.resetSearchForm()
- this.pageInit()
- }
- },
- activated () {
- // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
- if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
- this.resetSearchForm()
- this.pageInit()
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {})
- }
- }
- </script>
- <style lang="less">
- .inventoryQueryWarehouseDetail-wrap{
- .inventoryQueryWarehouseDetail-back{
- margin-bottom: 10px;
- }
- .inventoryQueryWarehouseDetail-cont{
- margin-bottom: 10px;
- }
- .green{
- color: #19be6b;
- }
- .red{
- color: #ed1c24;
- }
- }
- </style>
|