<template>
    <basic-container>
        <avue-crud :option="option" :table-loading="loading" :data="data" v-model="form" v-model:page="page" ref="crud"
            @row-del="rowDel" @search-change="searchChange" @search-reset="searchReset"
            @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
            @refresh-change="refreshChange" @on-load="onLoad">
            <template #leCode="{ row }">{{ row.stLend.leCode }}</template>
            <template #goodsCode="{ row }">{{ row.stLend.stRealtimeStock.coGoods.goodsCode }}</template>
            <template #goodsName="{ row }">{{ row.stLend.stRealtimeStock.coGoods.goodsName }}</template>
            <template #piNo="{ row }">{{ row.stLend.stRealtimeStock.piNo }}</template>
            <template #shName="{ row }">{{ row.stLend.stRealtimeStock.coStorehouse.shName }}</template>
            <template #location="{ row }">{{ row.stLend.stRealtimeStock.storageLocation.location }}</template>
            <template #quantity="{ row }">{{ row.stLend.quantity }}</template>
            <template #returnQty="{ row }">{{ row.stLend.returnQty }}</template>
            <template #unitName="{ row }">{{ row.stLend.stRealtimeStock.coGoods.unitName }}</template>
            <template #leDate="{ row }">{{ row.stLend.leDate }}</template>
            <template #leReturnDate="{ row }">{{ row.stLend.leReturnDate }}</template>
            <template #deptName="{ row }">{{ row.stLend.pfDepartment.deptName }}</template>
            <template #userName="{ row }">{{ row.stLend.leMan.userName }}</template>
            <template #createMan="{ row }">{{ row.createMan.userName }}</template>
            <template #curStatus="{ row }">
                {{ row.stLend.curStatus == 20 ? '已借出' : row.stLend.curStatus == 24 ?
                    '部分归还' : row.stLend.curStatus == 25 ? '已归还' : "新建" }}
            </template>
            <template #menu-left>
                <el-button type="primary" icon="el-icon-connection" @click="handleReturn">批量归还</el-button>
            </template>
        </avue-crud>
        <el-dialog title="批量归还" append-to-body v-model="returnDialog">
            <el-button plain type="danger" @click="remove">删除选择行</el-button>
            <el-button type="primary" @click="handleSave">保存</el-button>
            <el-table :data="returnData" style="margin-top: 10px;">
                <el-table-column type="selection"></el-table-column>
                <el-table-column label="物料编码" prop="stLend.stRealtimeStock.coGoods.goodsCode"></el-table-column>
                <el-table-column label="合格数" prop="passQty"></el-table-column>
                <el-table-column label="丢失数" prop="loseQty"></el-table-column>
                <el-table-column label="使用次数" prop="useNumber"></el-table-column>
            </el-table>
        </el-dialog>
    </basic-container>
</template>
<script>
export default {
    data() {
        return {
            loading: false,
            data: [],
            form: {},
            returnDialog:false,
            page: {
                pageSize: 10,
                currentPage: 1,
                total: 0,
            },
            returnData:[],
            option: {
                height: 'auto',
                calcHeight: 32,
                tip: false,
                size: 'medium',
                simplePage: true,
                searchShow: true,
                searchMenuSpan: 6,
                searchIcon: true,
                searchIndex: 3,
                tree: false,
                border: true,
                index: true,
                selection: true,
                viewBtn: true,
                delBtn: true,
                editBtnText: '修改',
                addBtnText:'借出',
                viewBtnIcon: ' ',
                delBtnIcon: ' ',
                editBtnIcon: ' ',
                viewBtnText: '详情',
                labelWidth: 150,
                menuWidth: 220,
                dialogWidth: 1500,
                dialogClickModal: false,
                searchEnter: true,
                excelBtn: false,
                filterBtn: true,
                searchShowBtn: false,
                columnSort: true,
                excelBtn: true,
                columnSort: true,
                index: false,
                showOverflowTooltip: true,
                searchLabelPosition:'left',
searchLabelPosition:'left',
 searchGutter:24,
  searchSpan:6,
menuAlign: 'left',
gridBtn:false,
searchMenuPosition:'right',
                column: [
                    {
                        label: '单据号',
                        prop: 'leCode',
                        addDisplay: true,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        order:12,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入单据号',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '物料编号',
                        prop: 'goodsCode',
                        addDisplay: true,
                        editDisplay: false,
                        order:11,
                        span: 6,
                        width: 200,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入物料编号',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '物料名称',
                        prop: 'goodsName',
                        addDisplay: true,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        order:8,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入物料名称',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '批号',
                        prop: 'piNo',
                        addDisplay: true,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        order:6,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入批号',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '库房号',
                        prop: 'shName',
                        addDisplay: false,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入库房号',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '库位号',
                        prop: 'location',
                        addDisplay: true,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        order:5,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入库位号',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '借出数量',
                        prop: 'quantity',
                        addDisplay: true,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        order:10,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入借出数量',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '退库数量',
                        prop: 'returnQty',
                        addDisplay: false,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入退库数量',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '单位',
                        prop: 'unitName',
                        addDisplay: true,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        order:2,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入单位',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '借出时间',
                        prop: 'leDate',
                        addDisplay: true,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        order: 16,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入借出时间',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '借出仓库',
                        prop: 'shId',
                        type: 'select',
                        addDisplay: true,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        order: 15,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入借出仓库',
                                trigger: 'click',
                            },
                        ],
                        dicData: [
                            { label: "仓库一", value: '001' },
                            { label: "仓库二", value: '002' },
                        ]
                    },
                    {
                        label: '计划归还',
                        prop: 'leReturnDate',
                        order:9,
                        type:'date',
                        addDisplay: true,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入计划归还',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '借用部门',
                        prop: 'deptName',
                        type: 'select',
                        addDisplay: true,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        order: 14,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入借用部门',
                                trigger: 'click',
                            },
                        ],
                        prop:{
                            label:"deptName",
                            value:'deptCode'
                        },
                        dicData: [
                            {
                                "appLink": null,
                                "createTime": "2022-08-31",
                                "deleted": false,
                                "deptCode": "001",
                                "deptId": 1,
                                "deptName": "MES开发部",
                                "deptType": 1,
                                "deptTypeTitle": "厂",
                                "keyValue": 1,
                                "memo": null,
                                "orders": "00",
                                "parentDeptId": null,
                                "parentPath": null,
                                "ucDeptId": null,
                                "updateTime": "2022-08-31 16:32:46"
                            },
                            {
                                "appLink": null,
                                "createTime": "2023-02-06",
                                "deleted": false,
                                "deptCode": "3400",
                                "deptId": 41,
                                "deptName": "热表分厂",
                                "deptType": 1,
                                "deptTypeTitle": "厂",
                                "keyValue": 41,
                                "memo": null,
                                "orders": "1",
                                "parentDeptId": null,
                                "parentPath": null,
                                "ucDeptId": null,
                                "updateTime": "2023-02-06 10:25:08"
                            },
                            {
                                "appLink": null,
                                "createTime": "2023-02-06",
                                "deleted": false,
                                "deptCode": "01",
                                "deptId": 42,
                                "deptName": "化学镀镍",
                                "deptType": 1,
                                "deptTypeTitle": "厂",
                                "keyValue": 42,
                                "memo": null,
                                "orders": "1",
                                "parentDeptId": 41,
                                "parentPath": null,
                                "ucDeptId": null,
                                "updateTime": "2023-02-06 10:26:13"
                            },
                        ]
                    },
                    {
                        label: '借用人',
                        prop: 'leReturnDate',
                        type:'select',
                        addDisplay: true,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        order:13,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入借用人',
                                trigger: 'click',
                            },
                        ],
                        dicData:[
                            {userId: 1,userName: "admin"},
                            {userId: 61,userName: "09391"},
                            {userId: 62,userName: "03764"},
                        ]
                    },
                    {
                        label: '本次归还合格数量',
                        prop: 'passQty',
                        addDisplay: false,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入本次归还合格数量',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '本次归还丢失数',
                        prop: 'loseQty',
                        addDisplay: false,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入本次归还丢失数',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '本次归还报废数',
                        prop: 'bfQty',
                        addDisplay: false,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入本次归还报废数',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '本次归还续借数',
                        prop: 'renewQty',
                        addDisplay: false,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入本次归还续借数',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '本次归还人',
                        prop: 'createMan',
                        addDisplay: false,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入本次归还人',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '本次使用次数',
                        prop: 'useNumber',
                        addDisplay: false,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入本次使用次数',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '本次归还时间',
                        prop: 'createTime',
                        addDisplay: false,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入本次归还时间',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '状态',
                        prop: 'curStatus',
                        addDisplay: false,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入状态',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '备注',
                        prop: 'curStatus',
                        type:'textarea',
                        addDisplay: true,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        order:1,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入备注',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '型号/牌号',
                        prop: 'specifications',
                        addDisplay: true,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        order:7,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入型号/牌号',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '库存量',
                        prop: 'stockNum',
                        addDisplay: true,
                        addDisabled:true,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        order:3,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入库存量',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '可用库存',
                        prop: 'useQuantity',
                        addDisplay: true,
                        addDisabled:true,
                        editDisplay: false,
                        span: 6,
                        width: 200,
                        order:3,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入可用库存',
                                trigger: 'click',
                            },
                        ],
                    },
                ]
            },
        }
    },
    mounted() {

    },
    methods: {
        handleReturn(){
            this.returnDialog = true
        },
        onLoad() {
            this.data = []
            this.page.total = this.data.length
        }
    }
}
</script>

<style></style>