done.vue 6.76 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.merChantCode.label">
                <Input v-model.trim="filters.merChantCode.model"
                       :placeholder="filters.merChantCode.holder"></Input>
            </FilterItem>
            <FilterItem :label="filters.prodBarCode.label">
                <Input v-model.trim="filters.prodBarCode.model"
                       :placeholder="filters.prodBarCode.holder"></Input>
            </FilterItem>
            <FilterItem :label="filters.orderTime.label">
                <Date-picker type="date" placeholder="选择日期"
                             @on-change="dateChange" :value="filters.orderTime.model"></Date-picker>
            </FilterItem>
            <FilterItem :label="filters.prodStatus.label">
                <Select v-model.trim="filters.prodStatus.model">
                    <Option v-for="option in filters.prodStatus.options"
                            :value="option.value"
                            :key="option.value">{{option.label}}</Option>
                </Select>
            </FilterItem>
            <FilterItem>
                <Button type="primary" @click="filterSearch">筛选</Button>
                <Button type="primary" @click="output">导出</Button>
                <Button @click="clearFilter">清空条件</Button>
            </FilterItem>
        </LayoutFilter>
        <LayoutList>
            <Table border :context="self" :columns="table.cols" :data="table.list"
                   :row-class-name="rowClassName" @on-selection-change="selectChange"></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/done';
    import { CellPrdInfo, CellDispatch } from 'components/cell';

    export default {
        name: 'TabDone',
        data() {
            return {
                self: this,
                filters: {},
                page: {},
                table: {},
                useFilterSign: false,
                showOutStock: true
            };
        },
        created() {
            const store = Store();

            this.filters = store.filters;
            this.page = store.page;
            this.table = store.table;

            const params = {
                pageNo: 1,
                statusList: [2,3]
            };

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

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

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

                if(date && moment(date).isValid()) {
                    data.startTime = +moment(date).format('X');
                    data.endTime = +moment(date).add(1, 'days').format('X');
                } else {
                    data.startTime = '';
                }

                if(status === -1) {
                    data.statusList = [2,3];
                } else if(status === -2){
                    data.statusList = [2];
                } else {
                    data.statusList = [+status];
                }

                data.isOvertime = ot === -2 ? 'Y' : '';

                console.log(data)

                return data;
            },
            productList(params){
                service.allotPurchaseList(
                    _.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.productList(params);
                this.page.current = 1;
            },
            clearFilter(){
                this.filters = Store().filters;
                this.productList();
                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.productList(params);
            },
            selectChange(){

            },
            sendOut(){

            },
            setModel(k, v) {
                this.filters[k].model = v;
            },
            dateChange(date){
                this.setModel('orderTime', date);
            },
            rowClassName(row) {
                if(row.isOvertime === 'Y') {
                    return 'over-time';
                }
                return '';
            },
            output() {

            }
        },
        components: {
            CellPrdInfo,
            CellDispatch
        }
    };
</script>

<style lang="scss">
    .ivu-table .over-time td{
        background-color: #2db7f5;
        color: #fff;
    }
</style>