<template>
    <div class="ele-body">
        <el-card shadow="never">
            <search ref="search" @search="reload"></search>
            <ele-pro-table ref="table" :columns="columns" :datasource="datasource" :pageSize="20"
                :pageSizes="[20, 30, 40, 50, 100]">
                <!-- 表头工具栏 -->
                <template v-slot:toolbar>

                </template>

                <template v-slot:sampleCode="{ row }">
                    <el-link type="primary" :underline="false">
                        {{ row.sampleCode }}
                    </el-link>
                </template>
            </ele-pro-table>
        </el-card>
    </div>
</template>
<script>
import search from './components/search.vue';

import { getQualitySampleList } from '@/api/samplemanagement';

import dictMixins from '@/mixins/dictMixins';

export default {
    mixins: [dictMixins],
    components: {
        search
    },
    data() {
        return {
            columns: [
                { type: 'index', columnKey: 'index', align: 'center', label: '序号', width: 55, showOverflowTooltip: true, fixed: 'left' },
                { label: '样品编码', prop: 'sampleCode', width: 120, showOverflowTooltip: true, align: 'center', fixed: 'left' },
                { label: '编码', prop: 'categoryCode', width: 120, showOverflowTooltip: true, align: 'center', fixed: 'left' },
                { label: '名称', prop: 'categoryName', width: 120, showOverflowTooltip: true, align: 'center' },
                { label: '批次号', prop: 'batchNo', align: 'center', width: 100, showOverflowTooltip: true },
                { label: '发货条码', prop: 'barcodes', align: 'center', width: 120, showOverflowTooltip: true },
                { label: '包装编码', prop: 'packageNo', align: 'center', width: 120, showOverflowTooltip: true },
                { label: '包装单位', prop: 'packingUnit', align: 'center', width: 100, showOverflowTooltip: true },
                { label: '计量数量', prop: 'measureQuantity', align: 'center', width: 100, showOverflowTooltip: true },
                { label: '计量单位', prop: 'measureUnit', align: 'center', width: 100, showOverflowTooltip: true },
                { label: '供应商名称', prop: 'supplierName', align: 'center', width: 120, showOverflowTooltip: true },
                { label: '供应商代号', prop: 'supplierCode', align: 'center', width: 120, showOverflowTooltip: true },
                { label: '物料代号', prop: 'materielDesignation', align: 'center', slot: 'materielDesignation', width: 100, showOverflowTooltip: true },
                { label: '客户代号', prop: 'clientCode', align: 'center', slot: 'clientCode', width: 100, showOverflowTooltip: true },
                { label: '刻码', prop: 'engrave', align: 'center', slot: 'engrave', showOverflowTooltip: true },
                { label: '重量', prop: 'weight', align: 'center', slot: 'weight', showOverflowTooltip: true },
                { label: '重量单位', prop: 'weightUnit', align: 'center', showOverflowTooltip: true },
                { label: '仓库', prop: 'warehouseName', align: 'center', width: 100, showOverflowTooltip: true },
                { label: '货区', prop: 'areaName', align: 'center', showOverflowTooltip: true },
                { label: '货架', prop: 'goodsShelfName', align: 'center', showOverflowTooltip: true },
                { label: '货位', prop: 'goodsAllocationName', align: 'center', showOverflowTooltip: true },
                { label: '生产日期', prop: 'productionDate', align: 'center', showOverflowTooltip: true },
                { label: '采购日期', prop: 'purchaseDate', align: 'center', showOverflowTooltip: true },
                {
                    label: '处置状态', prop: 'disposalStatus', align: 'center', formatter: (row, column, cellValue) => {
                        return cellValue == 7 ? '消耗' : '';
                    }
                },
                { label: '处置时间', prop: 'disposeTime', align: 'center', width: 100, showOverflowTooltip: true },
                {
                    label: '质检状态', prop: 'qualityStatus', align: 'center', formatter: (row, column, cellValue) => {
                        return cellValue == 0 ? '未检' : cellValue == 1 ? '已检' : cellValue == 2 ? '待检' : '';
                    }
                },
                {
                    label: '质检结果', prop: 'qualityResults', align: 'center', formatter: (row, column, cellValue) => {
                        return cellValue == 1 ? '合格' : cellValue == 2 ? '不合格' : '';
                    }
                },
            ]
        };
    },
    created() {
        // this.requestDict('取样类型');
    },
    methods: {
        datasource({ page, where, limit }) {
            where.disposalStatus = 7;
            return getQualitySampleList({
                ...where,
                pageNum: page,
                size: limit
            });
        },

        reload(where) {
            this.$refs.table.reload({ page: 1, where });
        },
        processingMethod(type, row) {
            this.$router.push({
                path: '/sample/samplemanagement/components/edit',
                query: {
                    type: type,
                    qualityWorkOrderId: row.qualityWorkOrderId || '',
                    id: row.id || '',
                    qualityType: row.qualityType || ''
                }
            });
            // this.$refs.edit.open(type, row)
        },
    }
};
</script>
