<template>
    <div>
        <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 #menu-left>
                <el-button type="primary" @click="reviewFn">审核</el-button>
            </template>
            <template #menu-right>

            </template>
            <template #menu>

            </template>

        </avue-crud>
        <reviewDailog v-if="isOpen" :showDialog="isOpen" :ids="ids" @closeDialog="closeDialog" @refresh="onLoad"></reviewDailog>
    </div>
</template>
<script>
import reviewDailog from './reviewDailog.vue'
import {getStatement} from "@/api/outsourcingManagement/oemOrderSettlement"
export default {
    components: {
        reviewDailog
    },
    data() {
        return {
            selectionList: [],
            data:[],
            loading:false,
            query:{},
            option: {
                height: 'auto',
                calcHeight: 32,
                tip: false,
                simplePage: true,
                searchShow: true,
                searchMenuSpan: 6,
                searchIcon: true,
                searchIndex: 3,
                tree: false,
                border: true,
                index: false,
                selection: true,
                rowKey: 'id',
                editBtn: false,
                viewBtn: false,
                delBtn: false,
                addBtn: false,
                editBtnText: '修改',
                viewBtnIcon: ' ',
                delBtnIcon: ' ',
                editBtnIcon: ' ',
                viewBtnText: '详情',
                labelWidth: 120,
                menuWidth: 180,
                dialogWidth: 640,
                dialogClickModal: false,
                searchEnter: true,
                excelBtn: true,
                filterBtn: true,
                searchShowBtn: false,
                columnSort: true,
                showOverflowTooltip: true,
                menu: false,
                searchLabelPosition: 'left',
                searchGutter: 24,
                searchSpan: 6,
                menuAlign: 'left',
                gridBtn: false,
                searchMenuPosition: 'right',
                addBtnIcon: ' ',
                viewBtnIcon: ' ',
                delBtnIcon: ' ',
                editBtnIcon: ' ',
                align: 'center',
                column: [
                    {
                        label: '外协单号',
                        prop: 'oemCode',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: true,
                        width: 120,
                        searchOrder:18,
                    },
                    {
                        label: '车间订单单号',
                        prop: 'woCode',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: true,
                        width: 140,
                        searchLabelWidth: 110,
                        searchOrder:19,
                    },
                    {
                        label: '零件号',
                        prop: 'partCode',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: true,
                        width: 120,
                        searchOrder:17,
                    },
                    {
                        label: '零件名称',
                        prop: 'partName',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: false,
                        width: 120,
                    },
                    {
                        label: '批次号',
                        prop: 'batchNo',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: true,
                        width: 120,
                        searchOrder:15,
                    },
                    {
                        label: '生产标识',
                        prop: 'prodIdent',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: true,
                        width: 120,
                        type:'select',
                        searchOrder:16,
                        dicUrl:"/api/blade-scheduling/qualityGrade/getGrades",
                        props:{
                            label:'qualityGrade',
                            value:"id"
                        }
                    },
                    {
                        label: '工序',
                        prop: 'psCode',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: true,
                        width: 120,
                        type:'select',
                        dicUrl:"/api/blade-desk/bsProcessSet/getProcessSetList",
                        props:{
                            label: 'name',
                            value: 'code',
                        },
                    },
                    {
                        label: '工艺能力',
                        prop: 'caName',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: false,
                        width: 120,
                    },
                    {
                        label: '镀后入库时间',
                        prop: 'putStoreTime',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: true,
                        width: 140,
                        searchLabelWidth: 110,
                        type: "date",
                        searchRange: true,
                        format: 'YYYY-MM-DD',
                        valueFormat: 'YYYY-MM-DD',
                        startPlaceholder: '开始时间',
                        endPlaceholder: '结束时间',
                        searchOrder:20,
                     
                    },
                    {
                        label: '生产数量',
                        prop: 'makeQty',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: false,
                        width: 120,
                    },
                    {
                        label: '单位面积(d㎡)',
                        prop: 'ypArea',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: false,
                        width: 140,
                    },
                    {
                        label: '总面积(d㎡)',
                        prop: 'totalArea',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: false,
                        width: 140,
                    },
                    {
                        label: '外协厂商',
                        prop: 'ocId',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: true,
                        width: 120,
                        type:'select',
                        dicUrl:"/api/blade-desk/BA/Oem/listForSelect",
                        props:{
                            label:'ocName',
                            value:"id"
                        }
                    },
                    {
                        label: '镀种',
                        prop: 'plate',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: false,
                        width: 120,
                    },
                    {
                        label: '镀层厚度',
                        prop: 'plateThickness',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: false,
                        width: 120,
                    },
                    {
                        label: '涂色标个数',
                        prop: 'tsbNum',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: false,
                        width: 120,
                    },
                    {
                        label: '涂色带个数',
                        prop: 'tsdNum',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: false,
                        width: 120,
                    },
                    {
                        label: '涂箭头个数',
                        prop: 'tjtNum',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: false,
                        width: 120,
                    },
                    {
                        label: '结算单价',
                        prop: 'settlePrice',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: false,
                        width: 120,
                    },
                    {
                        label: '计量单位',
                        prop: 'settleUnit',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: false,
                        width: 120,
                    },
                    {
                        label: '结算金额',
                        prop: 'settleAmount',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: false,
                        width: 120,
                    },
                    {
                        label: '报价单号',
                        prop: 'quoteCode',
                        sortable: true,
                        filter: true,
                        span: 24,
                        search: false,
                        width: 120,
                    },
                ]
            },
            form: {
                name: '',
            },
            page: {
                pageSize: 10,
                currentPage: 1,
                total: 0,
            },
            isOpen: false,
            ids: '',
        }
    },
    methods: {
        reviewFn() {
            if (this.selectionList.length === 0) {
                this.$message.warning('请选择至少一条数据');
                return;
            }
            this.ids = this.selectionList.map(item => item.id).join(',');
            this.isOpen = true
        },
        closeDialog() {
            this.isOpen = false
        },
        handleDelete() {
            if (this.selectionList.length === 0) {
                this.$message.warning('请选择至少一条数据');
                return;
            }
            this.$confirm('确定将选择数据删除?', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }).then(() => {
            })
        },
        // 多选
        selectionChange(list) {
            this.selectionList = list;
        },
        onLoad() {
            this.loading = true
            getStatement({
                current:this.page.currentPage,
                size:this.page.pageSize,
                rosStatusList:'2',
                ...this.query
            }).then(res =>{
                this.data = res.data.data.records
                this.page.total = res.data.data.total
                this.loading = false
            }).catch(() => {
                this.loading = false
            })
        }
    }
}
</script>
<style lang="scss" scoped></style>