<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 #goodsCode="{ row }">{{ row.coGoods.goodsCode }}</template>
            <template #goodsName="{ row }">{{ row.coGoods.goodsName }}</template>
            <template #bsBasicClass="{ row }">{{ row.bsBasicClass.name }}</template>
            <template #turnover="{ row }">{{ row.turnover.userName }}</template>
            <template #mtltmrk="{ row }">{{ row.coGoods.mtltmrk }}</template>
            <template #specifications="{ row }">{{ row.coGoods.specifications }}</template>
            <template #menu-left>
                <el-button type="danger" icon="el-icon-delete" @click="handleDelete">删除</el-button>
                <el-button type="primary"  >缺漆信息</el-button>
            </template>
            <template #menu-right>
                <el-button style="background: #e35767;color: #fff;">需报料</el-button>
                <el-button style="background: #ecec0f;color: #fff;">需跟踪</el-button>
                <el-button style="background: #00ffff;color: #fff;">待领料</el-button>
                <el-button style="background: #95f204;color: #fff;">正常</el-button>
                <el-button>长期未使用</el-button>
            </template>
        </avue-crud>
    </basic-container>
</template>

<script>
export default {
    data() {
        return {
            selectionList:[],
            loading: false,
            data: [],
            form: {},
            page: {
                pageSize: 10,
                currentPage: 1,
                total: 0,
            },
            option: {
                tip: false,
                align: 'center',
                size: 'medium',
                searchLabelWidth: 150,
                labelWidth: 150,
                simplePage: true,
                searchShow: true,
                searchMenuSpan: 6,
                searchIcon: true,
                searchIndex: 3,
                tree: false,
                border: true,
                selection: true,
                viewBtn: false,
                editBtn: true,
                addBtn: true,
                delBtn: false,
                editBtnText: '修改',
                editBtnIcon:' ',
                viewBtnText: '详情',
                // menuWidth: 330,
                dialogWidth: 1200,
                dialogClickModal: false,
                searchEnter: true,
                excelBtn: false,
                filterBtn: true,
                searchShowBtn: false,
                excelBtn: true,
                index: false,
                showOverflowTooltip: true,
                column: [
                    {
                        label: '物料编码',
                        prop: 'goodsCode',
                        type: 'select',
                        addDisplay: true,
                        editDisplay: true,
                        span: 8,
                        width: 200,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入物料编码',
                                trigger: 'click',
                            },
                        ],
                        props: {
                            label: 'goodsCode',
                            value: 'goodsId'
                        },
                        control: (val, form) => {
                            console.log('val-------------', val)
                            console.log('form-------------', form)
                            console.log('option-------------', this.option)
                            if (val) {
                                let tmp = this.option.column[0].dicData.find(item => item.goodsId == val)
                                form.goodsName = tmp && tmp.goodsName
                            }
                        },
                        dicData: [
                            {
                                "allGoodsQuantity": null,
                                "batch": null,
                                "bomQuantity": null,
                                "buyQuantity": null,
                                "cavityno": null,
                                "checkoutCode": "3333",
                                "coGoodsClass": null,
                                "coStorageLocation": null,
                                "cplb": null,
                                "createTime": "2023-07-15 16:18:30",
                                "curQuantity": 684.0,
                                "cycle": null,
                                "deleted": false,
                                "deliveryDate": null,
                                "dept": null,
                                "drawingNo": null,
                                "ecnno": null,
                                "enditem": 0,
                                "erpQuantity": null,
                                "goodsCode": "21E543-6108-B1-N",
                                "goodsCodeAndGoodsName": "null——21E543-6108-B1-N——石墨模",
                                "goodsId": 167,
                                "goodsName": "石墨模",
                                "grade": null,
                                "houseQuantity": null,
                                "lockQuantity": 0.0,
                                "madeIn": null,
                                "matbigclassify": null,
                                "matsmallclassify": null,
                                "maxNum": 300.0,
                                "memo": null,
                                "minNum": 50.0,
                                "mtlsgrt": 0.0,
                                "mtltmrk": "232",
                                "mustCheck": null,
                                "newGoodsName": null,
                                "newSpecifications": null,
                                "numAcc": null,
                                "onthewayQuantity": 0.0,
                                "partLink": null,
                                "piNo": null,
                                "price": 20.0,
                                "priority": null,
                                "prtType": "零件",
                                "prtrevedit": null,
                                "prtstd": null,
                                "prtwt": 0.0,
                                "purchaseQuantity": 100.0,
                                "releaseno": null,
                                "releasenoTime": "2023-03-23 00:00:00",
                                "remark": null,
                                "rlsId": null,
                                "singlePieceQuota": null,
                                "source": null,
                                "special": null,
                                "specifications": null,
                                "syQuantity": null,
                                "trademark": null,
                                "unitName": "每个",
                                "updateTime": "2023-07-15 16:18:30",
                                "used": true
                            },
                            {
                                "allGoodsQuantity": null,
                                "batch": null,
                                "bomQuantity": null,
                                "buyQuantity": null,
                                "cavityno": null,
                                "checkoutCode": "1111",
                                "coGoodsClass": null,
                                "coStorageLocation": null,
                                "cplb": null,
                                "createTime": "2023-07-15 16:18:30",
                                "curQuantity": 1950.0,
                                "cycle": null,
                                "deleted": false,
                                "deliveryDate": null,
                                "dept": null,
                                "drawingNo": null,
                                "ecnno": null,
                                "enditem": 0,
                                "erpQuantity": null,
                                "goodsCode": "04-05-025",
                                "goodsCodeAndGoodsName": "null——04-05-025——锡铂金",
                                "goodsId": 169,
                                "goodsName": "锡铂金",
                                "grade": null,
                                "houseQuantity": null,
                                "lockQuantity": 0.0,
                                "madeIn": null,
                                "matbigclassify": null,
                                "matsmallclassify": null,
                                "maxNum": 300.0,
                                "memo": null,
                                "minNum": 50.0,
                                "mtlsgrt": null,
                                "mtltmrk": "23",
                                "mustCheck": 0,
                                "newGoodsName": null,
                                "newSpecifications": null,
                                "numAcc": null,
                                "onthewayQuantity": 0.0,
                                "partLink": null,
                                "piNo": null,
                                "price": 30.0,
                                "priority": null,
                                "prtType": "零件",
                                "prtrevedit": null,
                                "prtstd": null,
                                "prtwt": 0.0,
                                "purchaseQuantity": 100.0,
                                "releaseno": null,
                                "releasenoTime": null,
                                "remark": null,
                                "rlsId": null,
                                "singlePieceQuota": null,
                                "source": null,
                                "special": null,
                                "specifications": "100克/瓶",
                                "syQuantity": null,
                                "trademark": null,
                                "unitName": "每克",
                                "updateTime": "2023-07-15 16:18:30",
                                "used": true
                            },
                            {
                                "allGoodsQuantity": null,
                                "batch": null,
                                "bomQuantity": null,
                                "buyQuantity": null,
                                "cavityno": null,
                                "checkoutCode": "2222",
                                "coGoodsClass": null,
                                "coStorageLocation": null,
                                "cplb": null,
                                "createTime": "2023-07-15 16:18:30",
                                "curQuantity": 2999.0,
                                "cycle": null,
                                "deleted": false,
                                "deliveryDate": null,
                                "dept": null,
                                "drawingNo": null,
                                "ecnno": null,
                                "enditem": 0,
                                "erpQuantity": null,
                                "goodsCode": "21E543-6108-B1",
                                "goodsCodeAndGoodsName": "null——21E543-6108-B1——石墨模",
                                "goodsId": 170,
                                "goodsName": "石墨模",
                                "grade": null,
                                "houseQuantity": null,
                                "lockQuantity": 0.0,
                                "madeIn": null,
                                "matbigclassify": null,
                                "matsmallclassify": null,
                                "maxNum": 300.0,
                                "memo": null,
                                "minNum": 50.0,
                                "mtlsgrt": null,
                                "mtltmrk": "4",
                                "mustCheck": 0,
                                "newGoodsName": null,
                                "newSpecifications": null,
                                "numAcc": null,
                                "onthewayQuantity": 0.0,
                                "partLink": null,
                                "piNo": null,
                                "price": 15.0,
                                "priority": null,
                                "prtType": "零件",
                                "prtrevedit": null,
                                "prtstd": null,
                                "prtwt": 0.0,
                                "purchaseQuantity": 0.0,
                                "releaseno": null,
                                "releasenoTime": null,
                                "remark": null,
                                "rlsId": null,
                                "singlePieceQuota": null,
                                "source": null,
                                "special": null,
                                "specifications": null,
                                "syQuantity": null,
                                "trademark": null,
                                "unitName": "每个",
                                "updateTime": "2023-07-15 16:18:30",
                                "used": true
                            }
                        ]
                    },
                    {
                        label: '物料名称',
                        prop: 'goodsName',
                        addDisabled: true,
                        addDisplay: true,
                        editDisplay: true,
                        span: 8,
                        width: 200,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入物料名称',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '季度月使用量均值',
                        prop: 'useAverage',
                        addDisplay: true,
                        editDisplay: true,
                        span: 8,
                        width: 200,
                        search: true,
                        // rules: [
                        //     {
                        //         required: true,
                        //         message: '请输入季度月使用量均值',
                        //         trigger: 'click',
                        //     },
                        // ],
                    },
                    {
                        label: '物料标记',
                        prop: 'bsBasicClass',
                        type: 'select',
                        addDisplay: true,
                        editDisplay: true,
                        span: 8,
                        width: 200,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入物料标记',
                                trigger: 'click',
                            },
                        ],
                        props: {
                            label: 'name',
                            value: 'code'
                        },
                        dicData: [
                            {
                                "bcId": 49,
                                "code": "11",
                                "deleted": false,
                                "keyValue": 49,
                                "memo": "11",
                                "name": "bj01",
                                "type": 1,
                                "updateTime": null
                            },
                            {
                                "bcId": 69,
                                "code": "bj02",
                                "deleted": false,
                                "keyValue": 69,
                                "memo": "22",
                                "name": "bj02",
                                "type": 1,
                                "updateTime": null
                            }
                        ]
                    },
                    {
                        label: '型号/牌号',
                        prop: 'mtltmrk',
                        addDisplay: false,
                        editDisplay: false,
                        span: 8,
                        width: 200,
                        search: false,
                        rules: [
                            {
                                required: true,
                                message: '请输入型号/牌号',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '物料规格',
                        prop: 'specifications',
                        addDisplay: false,
                        editDisplay: false,
                        span: 8,
                        width: 200,
                        search: false,
                        rules: [
                            {
                                required: true,
                                message: '请输入物料规格',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '一级库存',
                        prop: 'firstStore',
                        addDisplay: false,
                        editDisplay: false,
                        span: 8,
                        width: 200,
                        search: false,
                        rules: [
                            {
                                required: true,
                                message: '请输入一级库存',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '二级库存',
                        prop: 'lastStore',
                        addDisplay: false,
                        editDisplay: false,
                        span: 8,
                        width: 200,
                        search: false,
                        rules: [
                            {
                                required: true,
                                message: '请输入二级库存',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '计划数量',
                        prop: 'planQty',
                        addDisplay: false,
                        editDisplay: false,
                        span: 8,
                        width: 200,
                        search: false,
                        rules: [
                            {
                                required: true,
                                message: '请输入计划数量',
                                trigger: 'click',
                            },
                        ],
                    },
                    {
                        label: '是否油漆',
                        prop: 'paintName',
                        type: 'select',
                        addDisplay: true,
                        editDisplay: true,
                        span: 8,
                        width: 200,
                        search: false,
                        rules: [
                            {
                                required: true,
                                message: '请输入是否油漆',
                                trigger: 'click',
                            },
                        ],
                        dicData: [
                            { label: '是', value: 1 },
                            { label: '否', value: 0 },
                        ]
                    },
                    {
                        label: '周转工',
                        prop: 'turnover',
                        type:'select',
                        addDisplay: true,
                        editDisplay: true,
                        span: 8,
                        width: 200,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入周转工',
                                trigger: 'click',
                            },
                        ],
                        props:{
                            label:'userName',
                            value:'userId'
                        },
                        dicData: [
                            {
                                "jobName": "生产调度员",
                                "deptName": "外协业务交付管理室",
                                "deptId": 65,
                                "userName": "00188",
                                "userId": 441,
                                "userCode": "00188"
                            }, {
                                "jobName": "表面处理工",
                                "deptName": "复合镍班",
                                "deptId": 69,
                                "userName": "00460",
                                "userId": 224,
                                "userCode": "00460"
                            }, {
                                "jobName": "保管员",
                                "deptName": "零件管理班",
                                "deptId": 46,
                                "userName": "00660",
                                "userId": 322,
                                "userCode": "00660"
                            },
                        ]
                    },
                    {
                        label: '配送标记',
                        prop: 'deliveryName',
                        type: "select",
                        addDisplay: true,
                        editDisplay: true,
                        span: 8,
                        width: 200,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入配送标记',
                                trigger: 'click',
                            },
                        ],
                        dicData: [
                            { label: '是', value: 1 },
                            { label: '否', value: 0 },
                        ]
                    },
                    {
                        label: '是否特殊',
                        prop: 'specialName',
                        type: 'select',
                        addDisplay: true,
                        editDisplay: true,
                        span: 8,
                        width: 200,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入是否特殊',
                                trigger: 'click',
                            },
                        ],
                        dicData: [
                            { label: '是', value: 1 },
                            { label: '否', value: 0 },
                        ]
                    },
                    {
                        label: '状态',
                        prop: 'goodsStatusTitle',
                        type: 'select',
                        addDisplay: false,
                        editDisplay: false,
                        span: 8,
                        width: 200,
                        search: true,
                        rules: [
                            {
                                required: true,
                                message: '请输入状态',
                                trigger: 'click',
                            },
                        ],
                        dicData: [
                            {
                                value: 1,
                                label: '需报料'
                            }, {
                                value: 2,
                                label: '需跟踪'
                            }, {
                                value: 3,
                                label: '待领料'
                            }, {
                                value: 4,
                                label: '正常'
                            }, {
                                value: 5,
                                label: '长期未使用'
                            }
                        ]
                    },
                ]
            }
        }
    },
    mounted() {

    },
    methods: {
        selectionChange(val) {
            this.selectionList = val
        },
        handleDelete(){
            if (this.selectionList.length == 0) {
                this.$message.error('请至少选择一条数据')
            } else {
                this.$confirm('确定删除选中数据?', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning',
                }).then(() => {

                })
            }
        },
        onLoad() {
            this.data = [
                {
                    "bsBasicClass": {
                        "bcId": 49,
                        "code": "11",
                        "deleted": false,
                        "keyValue": 49,
                        "memo": "11",
                        "name": "bj01",
                        "type": 1,
                        "updateTime": null
                    },
                    "coGoods": {
                        "allGoodsQuantity": null,
                        "batch": null,
                        "bomQuantity": null,
                        "buyQuantity": null,
                        "cavityno": null,
                        "checkoutCode": "1111",
                        "coGoodsClass": null,
                        "coStorageLocation": null,
                        "cplb": null,
                        "createTime": "2023-07-15 16:18:30",
                        "curQuantity": 1950.0,
                        "cycle": null,
                        "deleted": false,
                        "deliveryDate": null,
                        "dept": null,
                        "drawingNo": null,
                        "ecnno": null,
                        "enditem": 0,
                        "erpQuantity": null,
                        "goodsCode": "04-05-025",
                        "goodsCodeAndGoodsName": "null——04-05-025——锡铂金",
                        "goodsId": 169,
                        "goodsName": "锡铂金",
                        "grade": null,
                        "houseQuantity": null,
                        "lockQuantity": 0.0,
                        "madeIn": null,
                        "matbigclassify": null,
                        "matsmallclassify": null,
                        "maxNum": 300.0,
                        "memo": null,
                        "minNum": 50.0,
                        "mtlsgrt": null,
                        "mtltmrk": "23",
                        "mustCheck": 0,
                        "newGoodsName": null,
                        "newSpecifications": null,
                        "numAcc": null,
                        "onthewayQuantity": 0.0,
                        "partLink": null,
                        "piNo": null,
                        "price": null,
                        "priority": null,
                        "prtType": "零件",
                        "prtrevedit": null,
                        "prtstd": null,
                        "prtwt": 0.0,
                        "purchaseQuantity": 100.0,
                        "releaseno": null,
                        "releasenoTime": null,
                        "remark": null,
                        "rlsId": null,
                        "singlePieceQuota": null,
                        "source": null,
                        "special": null,
                        "specifications": "100克/瓶",
                        "syQuantity": null,
                        "trademark": null,
                        "unitName": "每克",
                        "updateTime": "2023-07-15 16:18:30",
                        "used": true
                    },
                    "delivery": true,
                    "deliveryName": "是",
                    "firstStore": null,
                    "goodsStatus": 0,
                    "goodsStatusTitle": null,
                    "keyValue": {
                        "allGoodsQuantity": null,
                        "batch": null,
                        "bomQuantity": null,
                        "buyQuantity": null,
                        "cavityno": null,
                        "checkoutCode": "1111",
                        "coGoodsClass": null,
                        "coStorageLocation": null,
                        "cplb": null,
                        "createTime": "2023-07-15 16:18:30",
                        "curQuantity": 1950.0,
                        "cycle": null,
                        "deleted": false,
                        "deliveryDate": null,
                        "dept": null,
                        "drawingNo": null,
                        "ecnno": null,
                        "enditem": 0,
                        "erpQuantity": null,
                        "goodsCode": "04-05-025",
                        "goodsCodeAndGoodsName": "null——04-05-025——锡铂金",
                        "goodsId": 169,
                        "goodsName": "锡铂金",
                        "grade": null,
                        "houseQuantity": null,
                        "lockQuantity": 0.0,
                        "madeIn": null,
                        "matbigclassify": null,
                        "matsmallclassify": null,
                        "maxNum": 300.0,
                        "memo": null,
                        "minNum": 50.0,
                        "mtlsgrt": null,
                        "mtltmrk": "23",
                        "mustCheck": 0,
                        "newGoodsName": null,
                        "newSpecifications": null,
                        "numAcc": null,
                        "onthewayQuantity": 0.0,
                        "partLink": null,
                        "piNo": null,
                        "price": null,
                        "priority": null,
                        "prtType": "零件",
                        "prtrevedit": null,
                        "prtstd": null,
                        "prtwt": 0.0,
                        "purchaseQuantity": 100.0,
                        "releaseno": null,
                        "releasenoTime": null,
                        "remark": null,
                        "rlsId": null,
                        "singlePieceQuota": null,
                        "source": null,
                        "special": null,
                        "specifications": "100克/瓶",
                        "syQuantity": null,
                        "trademark": null,
                        "unitName": "每克",
                        "updateTime": "2023-07-15 16:18:30",
                        "used": true
                    },
                    "lastStore": null,
                    "paint": false,
                    "paintName": "否",
                    "planQty": null,
                    "special": false,
                    "specialName": "否",
                    "turnover": null,
                    "useAverage": null
                }
            ]
            this.page.total = this.data.length
        }
    }
}
</script>

<style></style>