list.vue 5.05 KB
<template>
    <LayoutBody>
        <LayoutFilter>
            <FilterItem :label="filters.id.label">
                <Input v-model.trim="filters.id.model" :number="true"
                       :placeholder="filters.id.holder" :maxlength="9"></Input>
            </FilterItem>

            <FilterItem :label="filters.expressNumber.label">
                <Input v-model.trim="filters.expressNumber.model" :number="true"
                       :placeholder="filters.expressNumber.holder" :maxlength="9"></Input>
            </FilterItem>

            <FilterItem :label="filters.productSkn.label">
                <Input v-model.trim="filters.productSkn.model" :number="true"
                       :placeholder="filters.productSkn.holder" :maxlength="9"></Input>
            </FilterItem>

            <FilterItem :label="filters.skuFactoryCode.label">
                <Input v-model.trim="filters.skuFactoryCode.model" :number="true"
                       :placeholder="filters.skuFactoryCode.holder" :maxlength="9"></Input>
            </FilterItem>

            <FilterItem>
                <Button type="primary" @click="getExpress">筛选</Button>
                <Button @click="clearFilters">清空条件</Button>
            </FilterItem>
        </LayoutFilter>

        <LayoutAction>
            <Button>导出</Button>
        </LayoutAction>

        <LayoutList>
            <Table border :columns="tableCols" :data="tableData"></Table>
            <Page :total="pageData.total" :current="pageData.current"
                  @on-change="pageChange" :page-size="20" show-total></Page>
        </LayoutList>

    </LayoutBody>
</template>

<script>
    import {tableCols, tableData, pageData} from './store/list-table';
    import expressService from 'services/express-service';

    export default {
        data() {
            return {
                tableCols: tableCols.call(this),
                tableData,
                pageData,
                filters: {
                    id: {
                        label: '入库单号',
                        labelSpan: 6,
                        model: '',
                        holder: '',
                        fieldSpan: 18
                    },
                    expressNumber: {
                        label: '物流单号',
                        labelSpan: 6,
                        model: '',
                        holder: '',
                        fieldSpan: 18
                    },
                    productSkn: {
                        label: 'SKN编码',
                        labelSpan: 6,
                        model: '',
                        holder: '',
                        fieldSpan: 18
                    },
                    skuFactoryCode: {
                        label: '商品条码',
                        labelSpan: 6,
                        model: '',
                        holder: '',
                        fieldSpan: 18
                    },
                }
            };
        },
        mounted() {
            this.getExpress();
        },
        methods: {
            clearFilters() {
                this.filters.id.model = null;
                this.filters.expressNumber.model = null;
                this.filters.productSkn.model = null;
                this.filters.skuFactoryCode.model = null;
                this.pageData.current = 1;
                this.pageData.total = 0;

                this.getExpress();
            },
            filtersParams() {
                let params = {};

                if (this.filters.id.model) {
                    params.proReqFormId = this.filters.id.model;
                }

                if (this.filters.expressNumber.model) {
                    params.expressNumber = this.filters.expressNumber.model;
                }

                if (this.filters.productSkn.model) {
                    params.productSkn = this.filters.productSkn.model;
                }

                if (this.filters.skuFactoryCode.model) {
                    params.skuFactoryCode = this.filters.skuFactoryCode.model;
                }

                params.pageSize = this.pageData.pageSize;
                params.pageNo = this.pageData.current;

                return Promise.resolve(params);
            },
            getExpress() {
                return this.filtersParams().then((params) => {
                    return expressService.list(params);
                }).then((result) => {
                    if (result.code === 200) {
                        this.pageData.total = result.data.totalCount;
                        this.pageData.current = result.data.pageNo;
                        this.tableData = result.data.records;
                    }
                });
            },
            info(data) {
                this.$router.push({
                    name: 'repository.express.info',
                    params: {
                        id: data.expressNumber
                    },
                    query: {
                        time: data.createTime
                    }
                });
            }
        }
    };
</script>