123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402 |
- <template>
- <a-card size="small" :bordered="false" class="shelfMonitoringList-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <!-- 搜索条件 -->
- <div ref="tableSearch" class="table-page-search-wrapper">
- <a-form-model
- id="shelfMonitoringList-form"
- ref="ruleForm"
- class="form-model-con"
- layout="inline"
- :model="queryParam"
- :rules="rules"
- :labelCol="labelCol"
- :wrapperCol="wrapperCol"
- @keyup.enter.native="handleSearch" >
- <a-row :gutter="15">
- <a-col :md="6" :sm="24">
- <a-form-model-item label="货架名称" prop="shelfSn">
- <shelfSList v-model="queryParam.shelfSn" @change="shelfChange"></shelfSList>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="货位号">
- <a-input id="shelfMonitoringList-shelfPlaceCode" v-model.trim="queryParam.shelfPlaceCode" allowClear placeholder="请输入货位号"/>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="产品编码">
- <a-input id="shelfMonitoringList-productCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
- </a-form-model-item>
- </a-col>
- <template v-if="advanced">
- <a-col :md="6" :sm="24">
- <a-form-model-item label="产品名称">
- <a-input id="shelfMonitoringList-productName" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="货位产品状态">
- <v-select
- v-model="queryParam.state"
- ref="state"
- id="shelfMonitoringList-state"
- code="SHELF_PRODUCT_STATE"
- placeholder="请选择货位产品状态"
- allowClear></v-select>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="滞销天数">
- <a-input-group>
- <a-row>
- <a-col :span="11">
- <a-input-number
- id="shelfMonitoringList-unsalableDaysBegin"
- v-model="queryParam.unsalableDaysBegin"
- :precision="0"
- :min="0"
- :max="999999"
- placeholder="起始天数"
- style="width: 100%;display: inline-block;" />
- </a-col>
- <a-col :span="2"><span style="display: block;text-align: center;line-height: 32px;">至</span></a-col>
- <a-col :span="11">
- <a-input-number
- id="shelfMonitoringList-unsalableDaysEnd"
- v-model="queryParam.unsalableDaysEnd"
- :precision="0"
- :min="0"
- :max="999999"
- placeholder="截止天数"
- style="width: 100%;display: inline-block;" />
- </a-col>
- </a-row>
- </a-input-group>
- </a-form-model-item>
- </a-col>
- </template>
- <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
- <a-button type="primary" @click="handleSearch" :disabled="disabled" id="shelfMonitoringList-refresh">查询</a-button>
- <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="shelfMonitoringList-reset">重置</a-button>
- <a-button
- type="primary"
- class="button-warning"
- @click="handleExport"
- :disabled="disabled"
- :loading="exportLoading"
- id="salesManagementList-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-model>
- </div>
- <!-- 未选择合作商 -->
- <div class="unChoose" v-show="!isSearch">
- <a-icon type="exclamation-circle" theme="filled" :style="{ fontSize: '18px', color: '#ff9900', verticalAlign: 'sub', marginRight: '5px' }" />
- <span>请选择一个货架后点击查询按钮</span>
- </div>
- <div v-show="isSearch">
- <div style="margin-bottom: 10px">
- <div style="display: inline-block;margin-right: 15px;vertical-align: middle;font-weight: bold;font-size: 14px;">
- <a-divider type="vertical" style="background: #FF7D0C;width: 3px;height: 16px;" />
- <span>{{ shelfName || '--' }}</span>
- </div>
- <a-button type="primary" class="button-error" id="shelfMonitoringList-export" @click="handleAddBack">新增调回单</a-button>
- <span style="margin-left: 5px">
- <template v-if="rowSelectionInfo&&rowSelectionInfo.selectedRowKeys.length > 0">
- {{ `已选 ${rowSelectionInfo.selectedRowKeys.length} 项` }}
- </template>
- </span>
- </div>
- <!-- 列表 -->
- <s-table
- class="sTable fixPagination"
- ref="table"
- :style="{ height: tableHeight+84.5+'px' }"
- size="small"
- :rowKey="(record) => record.shelfPlaceSn"
- :columns="columns"
- :data="loadData"
- rowKeyName="shelfPlaceSn"
- :row-selection="{ columnWidth: 40 }"
- @rowSelection="rowSelectionFun"
- :scroll="{ y: tableHeight }"
- :defaultLoadData="false"
- :showPagination="false"
- bordered>
- <!-- 绑定产品状态 -->
- <template slot="state" slot-scope="text, record">
- <a-tooltip placement="left" v-if="record.recallBillData&&record.replenishBillData">
- <template slot="title">
- <div v-if="record.recallBillData">{{ record.recallBillData.join(',') }}</div>
- <div v-if="record.replenishBillData">{{ record.replenishBillData.join(',') }}</div>
- </template>
- {{ record.stateDictValue }}
- <a-icon type="exclamation-circle" theme="filled" style="color: #39f;font-size: 16px;margin-left: 5px;vertical-align: middle;cursor: pointer;" />
- </a-tooltip>
- <span v-else>{{ record.stateDictValue }}</span>
- </template>
- <!-- 操作 -->
- <template slot="action" slot-scope="text, record">
- <a-button
- size="small"
- type="link"
- class="button-primary"
- @click="handleDetail(record)"
- id="shelfMonitoringList-warehousing-btn">出入库明细</a-button>
- </template>
- </s-table>
- </div>
- </a-spin>
- <!-- 新增调回单 -->
- <add-modal :openModal="openModal" :nowData="nowData" @ok="handleOk" @close="handleCancel" />
- </a-card>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { STable, VSelect } from '@/components'
- import addModal from './addModal.vue'
- import shelfSList from '@/views/common/shelfList'
- import { shelfControlList, exportShelfControlReport } from '@/api/shelf'
- import { downloadExcel } from '@/libs/JGPrint.js'
- export default {
- components: { STable, VSelect, addModal, shelfSList },
- mixins: [commonMixin],
- data () {
- return {
- spinning: false,
- advanced: true, // 高级搜索 展开/关闭
- labelCol: { span: 8 },
- wrapperCol: { span: 16 },
- tableHeight: 0,
- queryParam: { // 查询条件
- shelfSn: undefined,
- shelfPlaceCode: '',
- productCode: '',
- productName: '',
- state: undefined,
- unsalableDaysBegin: undefined,
- unsalableDaysEnd: undefined
- },
- rules: {
- 'shelfSn': [{ required: true, message: '请选择货架', trigger: 'change' }]
- },
- disabled: false, // 查询、重置、导出按钮是否可操作
- exportLoading: false, // 导出loading
- columns: [
- { title: '货位号', dataIndex: 'shelfPlaceCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '绑定产品编码', dataIndex: 'productCode', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '绑定产品名称', dataIndex: 'productName', width: '18%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '货位产品状态', dataIndex: 'stateDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '补货在途', dataIndex: 'replenishBillQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '调回在途', dataIndex: 'recallBillQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '当前库存', dataIndex: 'qty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '最大库容', dataIndex: 'maxQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '滞销天数', dataIndex: 'unsalableDays', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'left' }
- ],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- // 校验滞销天数数值范围
- if (this.checkValueRange()) {
- this.disabled = true
- this.spinning = true
- return shelfControlList(this.queryParam).then(res => {
- let data
- if (res.status == 200) {
- data = res.data
- for (var i = 0; i < data.length; i++) {
- data[i].no = i + 1
- }
- this.disabled = false
- }
- this.spinning = false
- return data
- })
- } else {
- const _this = this
- this.disabled = true
- this.spinning = true
- return new Promise(function (resolve, reject) {
- const data = []
- _this.disabled = false
- _this.spinning = false
- resolve(data)
- })
- }
- },
- rowSelectionInfo: null,
- isSearch: false,
- openModal: false, // 新增编辑 弹框
- shelfName: '', // 货架名称
- nowData: {
- list: [],
- shelfInfo: {}
- }
- }
- },
- methods: {
- // 校验滞销天数数值范围
- checkValueRange () {
- const isONull = this.queryParam.unsalableDaysBegin === null || this.queryParam.unsalableDaysBegin === undefined
- const isOEmpty = this.queryParam.unsalableDaysBegin === ''
- const isOZero = this.queryParam.unsalableDaysBegin === 0
- const isTNull = this.queryParam.unsalableDaysEnd === null || this.queryParam.unsalableDaysEnd === undefined
- const isTEmpty = this.queryParam.unsalableDaysEnd === ''
- const isTZero = this.queryParam.unsalableDaysEnd === 0
- // 第一个为空(可为null可为空字符)第二个不为空
- // 第一个不为空第二个为空(可为null可为空字符)
- // 第一个大于第二个
- if ((isONull || isOEmpty) && (this.queryParam.unsalableDaysEnd || isTZero)) {
- this.$message.info('请输入正确的滞销天数查询范围!')
- return false
- }
- if ((this.queryParam.unsalableDaysBegin || isOZero) && (isTNull || isTEmpty)) {
- this.$message.info('请输入正确的滞销天数查询范围!')
- return false
- }
- if (this.queryParam.unsalableDaysBegin > this.queryParam.unsalableDaysEnd) {
- this.$message.info('请输入正确的滞销天数查询范围!')
- return false
- }
- this.queryParam.unsalableDaysBegin = this.queryParam.unsalableDaysBegin > 999999999 ? 999999999 : this.queryParam.unsalableDaysBegin
- this.queryParam.unsalableDaysEnd = this.queryParam.unsalableDaysEnd > 999999999 ? 999999999 : this.queryParam.unsalableDaysEnd
- return true
- },
- rowSelectionFun (obj) {
- this.rowSelectionInfo = obj || null
- },
- // 货架 change
- shelfChange (val, obj) {
- this.shelfName = obj && obj.shelfName || ''
- this.queryParam.shelfSn = val
- },
- // 查询
- handleSearch () {
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- this.$refs.table.clearSelected()
- this.$refs.table.refresh(true)
- this.isSearch = true
- } else {
- console.log('error submit!!')
- return false
- }
- })
- },
- // 重置
- resetSearchForm () {
- this.isSearch = false
- this.queryParam.shelfSn = undefined
- this.queryParam.shelfPlaceCode = ''
- this.queryParam.productCode = ''
- this.queryParam.productName = ''
- this.queryParam.state = undefined
- this.queryParam.unsalableDaysBegin = undefined
- this.queryParam.unsalableDaysEnd = undefined
- this.$refs.table.clearSelected()
- this.handleSearch()
- },
- // 导出
- handleExport () {
- const _this = this
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- const params = _this.queryParam
- _this.exportLoading = true
- _this.spinning = true
- exportShelfControlReport(params).then(res => {
- downloadExcel(res, this.shelfName)
- _this.exportLoading = false
- _this.spinning = false
- })
- } else {
- return false
- }
- })
- },
- // 新增调回单
- handleAddBack () {
- if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRows.length < 1)) {
- this.$message.warning('请至少选择一个产品')
- } else {
- this.nowData.list = this.rowSelectionInfo && this.rowSelectionInfo.selectedRows || []
- this.nowData.shelfInfo = {
- shelfName: this.shelfName,
- shelfSn: this.queryParam.shelfSn
- }
- this.openModal = true
- }
- },
- // 详情
- handleDetail (row) {
- this.$router.push({ path: `/numsGoodsShelves/shelfMonitoring/warehouseDetail/${row.shelfPlaceSn}/${row.productSn}` })
- },
- handleOk () {
- this.$refs.table.refresh()
- this.$refs.table.clearSelected() // 清空表格选中项
- this.isSearch = true
- },
- handleCancel () {
- this.openModal = false
- },
- filterOption (input, option) {
- return (
- option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
- )
- },
- pageInit () {
- const _this = this
- this.$nextTick(() => { // 页面渲染完成后的回调
- _this.setTableH()
- })
- },
- setTableH () {
- const tableSearchH = this.$refs.tableSearch.offsetHeight
- this.tableHeight = window.innerHeight - tableSearchH - 245
- }
- },
- watch: {
- advanced (newValue, oldValue) {
- const _this = this
- setTimeout(() => {
- _this.setTableH()
- }, 400)
- },
- '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
- this.setTableH()
- }
- },
- mounted () {
- if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
- this.pageInit()
- this.resetSearchForm()
- }
- },
- activated () {
- // 如果是新页签打开,则重置当前页面
- if (this.$store.state.app.isNewTab) {
- this.pageInit()
- this.resetSearchForm()
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {})
- }
- }
- </script>
- <style lang="less">
- .shelfMonitoringList-wrap{
- .unChoose {
- text-align: center;
- margin: 280px 0 340px;
- font-size: 16px;
- }
- }
- </style>
|