express.vue 4.93 KB
<template>
    <div class="un-done">
        <LayoutFilter>
            <FilterItem :label="filters.orderNo.label">
                <Input v-model.trim.number="filters.orderNo.model"
                       :placeholder="filters.orderNo.holder"></Input>
            </FilterItem>
            <FilterItem :label="filters.expressNo.label">
                <Input v-model.trim="filters.expressNo.model"
                       :placeholder="filters.expressNo.holder"></Input>
            </FilterItem>
            <FilterItem :label="filters.prodCode.label">
                <Input v-model.trim.number="filters.prodCode.model"
                       :placeholder="filters.prodCode.holder"></Input>
            </FilterItem>
            <FilterItem :label="filters.prodBarCode.label">
                <Input v-model.trim="filters.prodBarCode.model"
                       :placeholder="filters.prodBarCode.holder"></Input>
            </FilterItem>
            <FilterItem>
                <Button type="primary" @click="filterSearch">筛选</Button>
                <Button @click="clearFilter">清空条件</Button>
            </FilterItem>
        </LayoutFilter>

        <LayoutList>
            <Table border :context="self" :columns="table.cols" :data="table.list"></Table>
            <Page :total="page.total" :current="page.current"
                  @on-change="pageChange" :page-size="20" show-total></Page>
        </LayoutList>
    </div>
</template>

<script>
    import _ from 'lodash';
    import moment from 'moment';
    import service from 'trade-service';
    import dataStore from '../store/express';

    export default {
        name: 'TabDone',
        data() {
            return {
                self: this,
                filters: {},
                page: {},
                table: {},
                useFilter: false
            };
        },
        created() {
            const store = dataStore();
            const params = {
                pageNo: 1,
                pageSize: 20,
                statusList: [2, 3]
            };

            this.page = store.page;
            this.table = store.table;
            this.filters = store.filters;
            this.getExpList(params);
        },
        methods: {
            getExpList(params) {
                service.allotExpressList(params)
                    .then(res => {
                        this.handleData(res.data);
                    });
            },
            filterSearch() {
                this.useFilter = true;
                this.getExpList(this.params());
                this.page.current = 1;
            },
            clearFilter() {
                this.useFilter = false;
                this.getExpList(this.params());
                this.page.current = 1;
                this.filters = dataStore().filters;
            },
            pageChange(page) {
                let params = this.params();
    
                params.pageNo = page;
                this.page.current = page;
                this.getExpList(params);
            },
            params() {
                const data = {
                    pageNo: 1,
                    pageSize: 20,
                    statusList: [2, 3]
                };
                const mapKeys = {
                    expressNumber: 'expressNo',
                    sknFactoryCode: 'prodCode',
                    skuFactoryCode: 'prodBarCode',
                    proRequisitionFormId: 'orderNo'
                };

                if (this.useFilter) {
                    let val;
    
                    _.each(mapKeys, (v, k) => {
                        val = '' + this.filters[v].model;
                        if (val.length) {
                            data[k] = this.filters[v].model;
                        }
                    });
                }

                if (typeof data.proRequisitionFormId !== 'undefined' &&
                    !_.isFinite(+data.proRequisitionFormId)) {
                    this.$Message.error('入库单号只能是数字', 3);
                    return;
                }

                if (typeof data.sknFactoryCode !== 'undefined' &&
                    !_.isFinite(+data.sknFactoryCode)) {
                    this.$Message.error('SKN编码只能是数字', 3);
                    return;
                }

                return data;
            },
            goExpDetail(expressNo) {
                this.$router.push({
                    name: 'trade.expdetail',
                    query: {
                        expressNo
                    }
                });
            },
            handleData(data) {
                const fmt = 'YYYY-MM-DD HH:mm:ss';
                const list = data.records;

                _.each(list, i => {
                    i.createTime = moment.unix(i.createTime).format(fmt);
                });

                this.table.list = list;
                this.page.total = data.totalCount;
            }
        }
    };
</script>

<style lang="scss">
</style>