123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- <template>
- <a-card size="small" :bordered="false" class="warehouseList-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <!-- 搜索条件 -->
- <div class="table-page-search-wrapper" ref="tableSearch">
- <a-form-model
- id="inventoryImport-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="8" :sm="24">
- <a-form-model-item label="导入时间" prop="time">
- <rangeDate ref="rangeDate" @change="dateChange" />
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="导入单号">
- <a-input id="inventoryImport-no" v-model.trim="queryParam.stockImportNo" allowClear placeholder="请输入导入单号"/>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
- <a-button type="primary" @click="handleSearch" :disabled="disabled" id="inventoryImport-refresh">查询</a-button>
- <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="inventoryImport-reset">重置</a-button>
- </a-col>
- </a-row>
- </a-form-model>
- </div>
- <!-- 导入按钮 -->
- <div class="table-operator">
- <a-button id="inventoryImport-add" type="primary" class="button-error" v-if="$hasPermissions('B_importContent')" @click="openGuideModal=true">库存导入</a-button>
- </div>
- <!-- 合计 -->
- <a-alert type="info" style="margin-bottom:10px">
- <div class="ftext" slot="message">
- 总单数:<strong>{{ (totalData && (totalData.totalRowSize || totalData.totalRowSize==0)) ? totalData.totalRowSize : '--' }}</strong>;
- 产品总数量:<strong>{{ (totalData && (totalData.productTotalQty || totalData.productTotalQty==0)) ? totalData.productTotalQty : '--' }}</strong>;
- <div v-if="$hasPermissions('M_ShowAllCost')" style="display: inline-block;">
- 总成本:<strong>{{ (totalData && (totalData.productTotalCost || totalData.productTotalCost==0)) ? toThousands(totalData.productTotalCost) : '--' }}</strong>。
- </div>
- </div>
- </a-alert>
- <!-- 列表 -->
- <s-table
- class="sTable"
- ref="table"
- size="small"
- :style="{ height: tableHeight+84.5+'px' }"
- :rowKey="(record) => record.stockImportSn"
- rowKeyName="stockImportSn"
- :columns="columns"
- :data="loadData"
- :defaultLoadData="false"
- bordered>
- <!-- 导入单号 -->
- <template slot="stockImportNo" slot-scope="text, record">
- <span class="table-td-link" v-if="$hasPermissions('B_inventoryImport-detail')" @click="handleDetail(record)">{{ record.stockImportNo }}</span>
- <span v-else>{{ record.stockImportNo || '--' }}</span>
- </template>
- </s-table>
- </a-spin>
- <!-- 库存导入 -->
- <importGuideModal :openModal="openGuideModal" @close="openGuideModal=false" @ok="hanldeImprotOk" />
- <!-- 库存导入详情 -->
- <a-modal
- centered
- class="chooseImport-modal"
- :footer="null"
- title="库存导入明细"
- v-model="openInventoryImportDetail"
- @cancel="openInventoryImportDetail=false;detailSn=undefined;"
- width="70%">
- <detailList ref="inventoryImportDeail" typeInfo="STOCK_IMPORT" :detailSn="detailSn"></detailList>
- </a-modal>
- </a-card>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { STable, VSelect } from '@/components'
- import rangeDate from '@/views/common/rangeDate.vue'
- import getDate from '@/libs/getDate.js'
- import importGuideModal from './importGuideModal.vue'
- import detailList from './detailList.vue'
- import { stockImportAllList, stockImportCount } from '@/api/stockImport'
- export default {
- components: { STable, VSelect, rangeDate, importGuideModal, detailList },
- mixins: [commonMixin],
- data () {
- return {
- spinning: false,
- labelCol: { span: 8 },
- wrapperCol: { span: 16 },
- tableHeight: 0,
- queryParam: { // 查询条件
- time: [
- getDate.getThreeMonthDays().starttime,
- getDate.getCurrMonthDays().endtime
- ],
- beginDate: '',
- endDate: '',
- stockImportNo: undefined,
- importType: 'STOCK_IMPORT'
- },
- openGuideModal: false,
- detailSn: undefined,
- openInventoryImportDetail: false,
- rules: {
- 'time': [{ required: true, message: '请选择导入时间', trigger: 'change' }]
- },
- disabled: false, // 查询、重置按钮是否可操作
- exportLoading: false,
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- const params = Object.assign(parameter, this.queryParam)
- this.spinning = true
- delete params.time
- return stockImportAllList(params).then(res => {
- let data
- if (res.status == 200) {
- data = res.data
- // 总计
- this.getCount(params)
- const no = (data.pageNo - 1) * data.pageSize
- for (var i = 0; i < data.list.length; i++) {
- data.list[i].no = no + i + 1
- }
- this.disabled = false
- }
- this.spinning = false
- return data
- })
- },
- totalData: null // 合计
- }
- },
- computed: {
- columns () {
- const _this = this
- const arr = [
- { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
- { title: '导入时间', dataIndex: 'importTime', width: '21%', align: 'center', customRender: function (text) { return text || '--' } },
- { title: '导入单号', dataIndex: 'stockImportNo', width: '18%', align: 'center', scopedSlots: { customRender: 'stockImportNo' } },
- { title: '款数', dataIndex: 'productTotalCategory', width: '18%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '数量', dataIndex: 'productTotalQty', width: '18%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
- // { title: '成本', dataIndex: 'totalCost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- ]
- if (this.$hasPermissions('M_ShowAllCost')) {
- arr.splice(5, 0, { title: '成本', dataIndex: 'productTotalCost', width: '20%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
- }
- return arr
- }
- },
- methods: {
- // 详情
- handleDetail (row) {
- this.openInventoryImportDetail = true
- this.detailSn = row.stockImportNo
- this.$nextTick(() => {
- this.$refs.inventoryImportDeail.handleSearch()
- })
- },
- // 合计
- getCount (params) {
- stockImportCount(params).then(res => {
- if (res.status == 200) {
- this.totalData = res.data
- } else {
- this.totalData = null
- }
- })
- },
- // 创建时间 change
- dateChange (date) {
- this.queryParam.time = date
- this.queryParam.beginDate = date[0] || ''
- this.queryParam.endDate = date[1] || ''
- },
- // 查询
- handleSearch () {
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- this.$refs.table.refresh(true)
- } else {
- console.log('error submit!!')
- return false
- }
- })
- },
- // 库存导入
- hanldeImprotOk () {
- this.$refs.table.refresh(true)
- },
- // 重置
- resetSearchForm (flag) {
- this.queryParam.time = [
- getDate.getThreeMonthDays().starttime,
- getDate.getCurrMonthDays().endtime
- ]
- this.$refs.rangeDate.resetDate(this.queryParam.time)
- this.queryParam.beginDate = getDate.getThreeMonthDays().starttime
- this.queryParam.endDate = getDate.getCurrMonthDays().endtime
- this.$refs.ruleForm.resetFields()
- this.queryParam.stockImportNo = undefined
- this.totalData = null
- this.$refs.table.clearTable()
- this.handleSearch()
- },
- setTableH () {
- const tableSearchH = this.$refs.tableSearch.offsetHeight
- this.tableHeight = window.innerHeight - tableSearchH - 276
- },
- pageInit () {
- const _this = this
- this.$nextTick(() => { // 页面渲染完成后的回调
- _this.setTableH()
- })
- }
- },
- watch: {
- '$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>
|