tab-express.vue 5.39 KB
<template>
    <div class="un-done">
        <LayoutFilter>
            <FilterItem :label="filters.orderNo.label">
                <Input v-model.trim="filters.orderNo.model"
                       :placeholder="filters.orderNo.holder" number></Input>
            </FilterItem>
            <FilterItem :label="filters.expressNo.label">
                <Input v-model.trim="filters.expressNo.model"
                       :placeholder="filters.expressNo.holder" number></Input>
            </FilterItem>
            <FilterItem :label="filters.prodCode.label">
                <Input v-model.trim="filters.prodCode.model"
                       :placeholder="filters.prodCode.holder" number></Input>
            </FilterItem>
            <FilterItem :label="filters.expressStatus.label">
                <Select v-model.trim="filters.expressStatus.model">
                    <Option v-for="option in filters.expressStatus.options"
                            :value="option.value"
                            :key="option.value">{{option.label}}</Option>
                </Select>
            </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 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 Store from '../store/express';

    export default {
        name: 'TabDone',
        data() {
            return {
                self: this,
                filters: {},
                page: {},
                table: {},
                useFilterSign: false,
                showOutStock: true
            };
        },
        created() {
            const store = Store();
            const params = {
                pageNo: 1,
                statusList: [3] // TODO
            };

            this.page = store.page;
            this.table = store.table;
            this.filters = store.filters;
            this.expressList(params);
        },
        methods: {
            expressList(params){
                service.allotExpressList(
                    _.merge(params || {}, {
                        pageSize: 20
                    }))
                    .then(res => {
                        const fmt = 'YYYY-MM-DD HH:mm:ss';
                        const list = res.data.records;

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

                        this.table.list = list;
                        this.page.total = res.data.totalCount;
                    });
            },
            filterSearch(){
                const params = this.params();

                this.useFilterSign = true;
                this.expressList(params);
                this.page.current = 1;
            },
            clearFilter(){
                this.filters = Store().filters;
                this.expressList();
                this.useFilterSign = false;
                this.page.current = 1;
            },
            pageChange(page) {
                let params = {};
                this.page.current = page;

                if(this.useFilterSign) {
                    params = this.params();
                }

                _.merge(params, {
                    page
                });

                this.expressList(params);
            },
            params(){
                const data = {};
                const mapKeys = {
                    proRequisitionFormId: 'orderNo',
                    productSkn: 'prodCode',
                    sknFactoryCode: 'merChantCode',
                    skuFactoryCode: 'prodBarCode',
                    startTime: 'orderTime',
                    endTime: 'orderTime',
                    isOvertime: 'prodStatus'
                };

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

                const ot = data.isOvertime;
                const date = data.startTime.trim();

                if(date && moment(date).isValid()) {
                    data.startTime = +moment(date).format('X');
                    data.endTime = +moment(date).add(1, 'days').format('X');
                } else {
                    data.endTime = '';
                    data.startTime = '';
                }
                data.isOvertime = ot === -1 ? '' : ( ot === 1 ? 'N' : 'Y');

                return data;
            },
            expressDetail(expressNo) {
                this.$router.push({
                    name: 'trade.expdetail',
                    query: {
                        expressNo
                    }
                });
            }

        }
    };
</script>

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