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

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

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

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

            this.page = store.page;
            this.table = store.table;
            this.filters = store.filters;
            this.getExpList(params);
        },
        methods: {
            getExpList(params) {
                this.$Loading.start();
                this.tradeService.allotExpressList(params)
                    .then(res => {
                        this.$Loading.finish();
                        this.handleData(res.data);
                    });
            },
            filterSearch() {
                this.useFilter = true;
                if (this.params()) {
                    this.getExpList(this.params());
                    this.page.current = 1;
                }
            },
            clearFilter() {
                this.useFilter = false;
                if (this.params()) {
                    this.getExpList(this.params());
                    this.page.current = 1;
                }
                this.filters = dataStore.apply(this).filters;
            },
            pageChange(page) {
                let params = this.params();

                params.pageNo = page;
                this.page.current = page;
                this.getExpList(params);
            },
            params() {
                const data = {
                    pageNo: 1,
                    pageSize: 20,
                    sellTypes: [7],
                    statusList: [2, 3]
                };
                const mapKeys = {
                    skn: 'prodCode',
                    proReqFormId: 'orderNo',
                    expressNumber: 'expressNo',
                    skuFactoryCode: 'prodBarCode'
                };

                if (!this.useFilter) {
                    return data;
                }

                let val;

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

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

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

                return data;
            },
            goExpDetail(expressNo) {
                this.$router.push({
                    name: 'trade.expdetail',
                    query: {
                        expressNo
                    }
                });
            },
            handleData(data) {
                this.table.list = data.records;
                this.page.total = data.totalCount;
            }
        }
    };
</script>

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