<template>
    <basic-container>
        <!-- 领料出库 -->
        <avue-crud :option="option" :table-loading="loading" :data="data" v-model="form" v-model:page="page" ref="crud"
            @search-change="searchChange" @search-reset="searchReset" :before-open="beforeOpen"
            @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
            @refresh-change="refreshChange" @on-load="onLoad" @row-save="rowSave">
            <template #menu-left>
                <el-button type="primary" icon="el-icon-document-checked" @click="handleOut">出库</el-button>
            </template>
            <template #mtltmrk="{row}">{{ row.coGoods.mtltmrk }}</template>
            <template #checkoutCode="{row}">{{ row.coGoods.checkoutCode }}</template>
            <template #stRealtimeStock="{row}">{{ row.stRealtimeStock.quantity }}</template>
            <template #userName="{row}">{{ row.crMan.userName }}</template>
            <template #unitName="{row}">{{ row.coGoods.unitName }}</template>
        </avue-crud>
    </basic-container>
</template>
<script>
export default {
    data() {
        return {
            loading: false,
            data: [],
            form: {},
            page: {
                pageSize: 10,
                currentPage: 1,
                total: 0,
            },
            selectionList:[],
            option: {
                columnSort: true,
                tip: false,
                height: 'auto',
                align: 'center',
                calcHeight: 32,
                simplePage: false,
                searchShow: true,
                searchMenuSpan: 6,
                searchIcon: true,
                searchIndex: 3,
                tree: false,
                border: true,
                index: false,
                selection: true,
                viewBtn: false,
                delBtn: true,
                editBtn: true,
                editBtnText: '修改',
                editBtnIcon: ' ',
                delBtnIcon: ' ',
                addBtn: false,
                labelWidth: 140,
                searchLabelWidth: 120,
                menu: true,
                menuWidth: 200,
                dialogWidth: 1200,
                dialogClickModal: false,
                searchEnter: true,
                excelBtn: true,
                gridBtn: false,
                searchShowBtn: false,
                showOverflowTooltip: true,
                column: [
                    {
                        label: '提请物料',
                        // addDisabled: true,
                        prop: 'goodsCode',
                        span: 8,
                        overflow: true,
                        search: true,
                        // hide: false,
                        // order: 17,
                        rules: [
                            {
                                required: true,
                                message: '请输入提请物料',
                                trigger: 'blur',
                            },
                        ],
                    },
                    {
                        label: '物料名称',
                        prop: 'goodsName',
                        span: 8,
                        overflow: true,
                        search: true,
                        // hide: false,
                        // order: 17,
                        rules: [
                            {
                                required: true,
                                message: '请输入物料名称',
                                trigger: 'blur',
                            },
                        ],
                    },
                    {
                        label: '型号/牌号',
                        prop: 'mtltmrk',
                        span: 8,
                        overflow: true,
                        search: false,
                        // hide: false,
                        // order: 17,
                        rules: [
                            {
                                required: true,
                                message: '请输入型号/牌号',
                                trigger: 'blur',
                            },
                        ],
                    },
                    {
                        label: '规格',
                        prop: 'specifications',
                        span: 8,
                        overflow: true,
                        search: false,
                        // hide: false,
                        // order: 17,
                        rules: [
                            {
                                required: true,
                                message: '请输入规格',
                                trigger: 'blur',
                            },
                        ],
                    },
                    {
                        label: '质量编号',
                        prop: 'checkoutCode',
                        span: 8,
                        overflow: true,
                        search: false,
                        // hide: false,
                        // order: 17,
                        rules: [
                            {
                                required: true,
                                message: '请输入质量编号',
                                trigger: 'blur',
                            },
                        ],
                    },
                    {
                        label: '当前库存',
                        prop: 'stRealtimeStock',
                        span: 8,
                        overflow: true,
                        search: false,
                        // hide: false,
                        // order: 17,
                        rules: [
                            {
                                required: true,
                                message: '请输入当前库存',
                                trigger: 'blur',
                            },
                        ],
                    },
                    {
                        label: '提请数量',
                        prop: 'quantity',
                        span: 8,
                        overflow: true,
                        search: false,
                        // hide: false,
                        // order: 17,
                        rules: [
                            {
                                required: true,
                                message: '请输入提请数量',
                                trigger: 'blur',
                            },
                        ],
                    },
                    {
                        label: '出库库位',
                        prop: 'crId',
                        span: 8,
                        overflow: true,
                        search: false,
                        // hide: false,
                        // order: 17,
                        rules: [
                            {
                                required: true,
                                message: '请输入出库库位',
                                trigger: 'blur',
                            },
                        ],
                    },
                    {
                        label: '出库数量',
                        prop: 'outQuantity',
                        span: 8,
                        overflow: true,
                        search: false,
                        // hide: false,
                        // order: 17,
                        rules: [
                            {
                                required: true,
                                message: '请输入出库数量',
                                trigger: 'blur',
                            },
                        ],
                    },
                    {
                        label: '提请人',
                        prop: 'userName',
                        span: 8,
                        overflow: true,
                        search: true,
                        // hide: false,
                        // order: 17,
                        rules: [
                            {
                                required: true,
                                message: '请输入提请人',
                                trigger: 'blur',
                            },
                        ],
                    },
                    {
                        label: '提请日期',
                        prop: 'crDate',
                        type:'date',
                        searchRange:true,
                        span: 8,
                        overflow: true,
                        search: true,
                        // hide: false,
                        // order: 17,
                        rules: [
                            {
                                required: true,
                                message: '请输入提请日期',
                                trigger: 'blur',
                            },
                        ],
                    },
                    {
                        label: '备注',
                        prop: 'memo',
                        span: 8,
                        overflow: true,
                        search: false,
                        // hide: false,
                        // order: 17,
                        rules: [
                            {
                                required: true,
                                message: '请输入备注',
                                trigger: 'blur',
                            },
                        ],
                    },
                    {
                        label: '单位',
                        prop: 'unitName',
                        span: 8,
                        overflow: true,
                        search: false,
                        // hide: false,
                        // order: 17,
                        rules: [
                            {
                                required: true,
                                message: '请输入单位',
                                trigger: 'blur',
                            },
                        ],
                    },
                ]
            }
        }
    },
    mounted() {

    },
    methods: {
        // 多选
        selectionChange(list) {
            this.selectionList = list;
        },
        // 批量出库
        handleOut(){
            if(this.selectionList.length && this.selectionList.length != 0){

            }else{
                this.$message.warning('请先选择数据');
            }
        },
        onLoad(){
            this.data = []
            this.page.total = this.data.length
        }
    }
}
</script>