<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
                 label-width="68px">
                <el-form-item label="样品量字码" prop="sampleCode" label-width="100">
                    <el-input
                            v-model="queryParams.sampleCode"
                            placeholder="请输入样品量字码"
                            clearable
                            @keyup.enter.native="handleQuery"
                    />
                </el-form-item>
                <!--
                <el-form-item label="大节点" prop="typeCode">
                    <el-input
                            v-model="queryParams.typeCode"
                            placeholder="请输入大节点"
                            clearable
                            @keyup.enter.native="handleQuery"
                    />
                </el-form-item>

                <el-form-item label="小节点" prop="checkType">
                    <el-input
                            v-model="queryParams.checkType"
                            placeholder="请输入大节点"
                            clearable
                            @keyup.enter.native="handleQuery"
                    />
                </el-form-item>
                -->
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>

        <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
                <el-button
                        type="primary"
                        plain
                        icon="el-icon-plus"
                        size="mini"
                        @click="handleAdd"
                        v-hasPermi="['quality:aql:add']"
                >新增
                </el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button
                        type="success"
                        plain
                        icon="el-icon-edit"
                        size="mini"
                        :disabled="single"
                        @click="handleUpdate"
                        v-hasPermi="['quality:aql:edit']"
                >修改
                </el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button
                        type="danger"
                        plain
                        icon="el-icon-delete"
                        size="mini"
                        :disabled="multiple"
                        @click="handleDelete"
                        v-hasPermi="['quality:aql:remove']"
                >删除
                </el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button
                        type="warning"
                        plain
                        icon="el-icon-download"
                        size="mini"
                        @click="handleExport"
                        v-hasPermi="['quality:aql:export']"
                >导出
                </el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button
                        type="success"
                        plain
                        icon="el-icon-edit"
                        size="mini"
                        @click="handleUpdateCode"
                        v-hasPermi="['quality:aql:edit']"
                >维护样本量
                </el-button>
            </el-col>
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>

        <el-table v-loading="loading" :data="aqlList" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" align="center"/>
            <el-table-column label="id" align="center" prop="id" v-if="false"/>
            <el-table-column label="样品量字码" align="center" prop="sampleCode" width="100"/>
            <el-table-column label="样品量" align="center" prop="sampleCode"/>
            <el-table-column label="大节点" align="center" prop="typeCode"/>
            <el-table-column label="小节点" align="center" prop="checkType"/>
            <el-table-column label="接收质量限AQL" align="left">
                <el-table-column label="0.010" align="center" prop="aql1"/>
                <el-table-column label="0.015" align="center" prop="aql2"/>
                <el-table-column label="0.025" align="center" prop="aql3"/>
                <el-table-column label="0.040" align="center" prop="aql4"/>
                <el-table-column label="0.065" align="center" prop="aql5"/>
                <el-table-column label="0.10" align="center" prop="aql6"/>
                <el-table-column label="0.15" align="center" prop="aql7"/>
                <el-table-column label="0.25" align="center" prop="aql8"/>
                <el-table-column label="0.40" align="center" prop="aql9"/>
                <el-table-column label="0.65" align="center" prop="aql10"/>
                <el-table-column label="1.0" align="center" prop="aql11"/>
                <el-table-column label="1.5" align="center" prop="aql12"/>
                <el-table-column label="2.5" align="center" prop="aql13"/>
                <el-table-column label="4.0" align="center" prop="aql14"/>
                <el-table-column label="6.5" align="center" prop="aql15"/>
                <el-table-column label="10" align="center" prop="aql16"/>
                <el-table-column label="15" align="center" prop="aql17"/>
                <el-table-column label="25" align="center" prop="aql18"/>
                <el-table-column label="40" align="center" prop="aql19"/>
                <el-table-column label="65" align="center" prop="aql20"/>
                <el-table-column label="100" align="center" prop="aql21"/>
                <el-table-column label="150" align="center" prop="aql22"/>
                <el-table-column label="250" align="center" prop="aql23"/>
                <el-table-column label="400" align="center" prop="aql24"/>
                <el-table-column label="650" align="center" prop="aql25"/>
                <el-table-column label="1000" align="center" prop="aql26"/>
            </el-table-column>
        </el-table>

        <pagination
                v-show="total>0"
                :total="total"
                :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize"
                @pagination="getList"
        />

        <!-- 添加或修改抽样规则-接收质量限对话框 -->
        <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
            <el-form ref="form" :model="form" :rules="rules" label-width="80px">
                <el-form-item label="样品量字码开始" prop="sampleCode">
                    <el-input v-model="form.sampleCode" placeholder="请输入样品量字码开始"/>
                </el-form-item>
                   <!--
                <el-form-item label="最大坏量" prop="maxBadQuality">
                    <el-input v-model="form.maxBadQuality" placeholder="请输入最大坏量"/>
                </el-form-item>
             
                <el-form-item label="大节点" prop="typeCode">
                    <el-input v-model="form.typeCode" placeholder="请输入大节点"/>
                </el-form-item>-->

                <el-form-item label="0.010" prop="aql1">
                    <el-input v-model="form.aql1" placeholder="请输入0.010"/>
                </el-form-item>
                <el-form-item label="0.015" prop="aql2">
                    <el-input v-model="form.aql2" placeholder="请输入0.015"/>
                </el-form-item>
                <el-form-item label="0.025" prop="aql3">
                    <el-input v-model="form.aql3" placeholder="请输入0.025"/>
                </el-form-item>
                <el-form-item label="0.040" prop="aql4">
                    <el-input v-model="form.aql4" placeholder="请输入0.040"/>
                </el-form-item>
                <el-form-item label="0.065" prop="aql5">
                    <el-input v-model="form.aql5" placeholder="请输入0.065"/>
                </el-form-item>
                <el-form-item label="0.10" prop="aql6">
                    <el-input v-model="form.aql6" placeholder="请输入0.10"/>
                </el-form-item>
                <el-form-item label="0.15" prop="aql7">
                    <el-input v-model="form.aql7" placeholder="请输入0.15"/>
                </el-form-item>
                <el-form-item label="0.25" prop="aql8">
                    <el-input v-model="form.aql8" placeholder="请输入0.25"/>
                </el-form-item>
                <el-form-item label="0.40" prop="aql9">
                    <el-input v-model="form.aql9" placeholder="请输入0.40"/>
                </el-form-item>
                <el-form-item label="0.65" prop="aql10">
                    <el-input v-model="form.aql10" placeholder="请输入0.65"/>
                </el-form-item>
                <el-form-item label="1.0" prop="aql11">
                    <el-input v-model="form.aql11" placeholder="请输入1.0"/>
                </el-form-item>
                <el-form-item label="1.5" prop="aql12">
                    <el-input v-model="form.aql12" placeholder="请输入1.5"/>
                </el-form-item>
                <el-form-item label="2.5" prop="aql13">
                    <el-input v-model="form.aql13" placeholder="请输入2.5"/>
                </el-form-item>
                <el-form-item label="4.0" prop="aql14">
                    <el-input v-model="form.aql14" placeholder="请输入4.0"/>
                </el-form-item>
                <el-form-item label="6.5" prop="aql15">
                    <el-input v-model="form.aql15" placeholder="请输入6.5"/>
                </el-form-item>
                <el-form-item label="10" prop="aql16">
                    <el-input v-model="form.aql16" placeholder="请输入10"/>
                </el-form-item>
                <el-form-item label="15" prop="aql17">
                    <el-input v-model="form.aql17" placeholder="请输入15"/>
                </el-form-item>
                <el-form-item label="25" prop="aql18">
                    <el-input v-model="form.aql18" placeholder="请输入25"/>
                </el-form-item>
                <el-form-item label="40" prop="aql19">
                    <el-input v-model="form.aql19" placeholder="请输入40"/>
                </el-form-item>
                <el-form-item label="65" prop="aql20">
                    <el-input v-model="form.aql20" placeholder="请输入65"/>
                </el-form-item>
                <el-form-item label="100" prop="aql21">
                    <el-input v-model="form.aql21" placeholder="请输入100"/>
                </el-form-item>
                <el-form-item label="150" prop="aql22">
                    <el-input v-model="form.aql22" placeholder="请输入150"/>
                </el-form-item>
                <el-form-item label="250" prop="aql23">
                    <el-input v-model="form.aql23" placeholder="请输入250"/>
                </el-form-item>
                <el-form-item label="400" prop="aql24">
                    <el-input v-model="form.aql24" placeholder="请输入400"/>
                </el-form-item>
                <el-form-item label="650" prop="aql25">
                    <el-input v-model="form.aql25" placeholder="请输入650"/>
                </el-form-item>
                <el-form-item label="1000" prop="aql26">
                    <el-input v-model="form.aql26" placeholder="请输入1000"/>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitForm">确 定</el-button>
                <el-button @click="cancel">取 消</el-button>
            </div>
        </el-dialog>
        
        <!-- 样品量字码对话框 -->
        <el-dialog title="样品量字码维护" :visible.sync="openCode" width="1160px" append-to-body>
            <CodeContent></CodeContent>
            <div slot="footer" class="dialog-footer">
                <el-button @click="cancel">关 闭</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
    import {listAql,getAql,delAql, addAql,updateAql } from "@/api/quality/aql";
    import CodeContent from "./codeContent.vue";
    export default {
        name: "Aql",
        dicts: [],
        components: { CodeContent },
        data() {
            return {
                // 遮罩层
                loading: true,
                // 选中数组
                ids: [],
                // 非单个禁用
                single: true,
                // 非多个禁用
                multiple: true,
                // 显示搜索条件
                showSearch: true,
                // 总条数
                total: 0,
                // 抽样规则-接收质量限表格数据
                 aqlList: [],
                // 弹出层标题
                title: "",
                // 是否显示弹出层
                open: false,
                openCode: false,
                // 查询参数
                queryParams: {
                    pageNum: 1,
                    pageSize: 10,
                    sampleCode: null,
                    sampleAql: null,
                    attr1: null,
                    factoryCode: null,
                    maxBadQuality: null,
                    checkType: null,
                    typeCode: null,
                    aql1: null,
                    aql2: null,
                    aql3: null,
                    aql4: null,
                    aql5: null,
                    aql6: null,
                    aql7: null,
                    aql8: null,
                    aql9: null,
                    aql10: null,
                    aql11: null,
                    aql12: null,
                    aql13: null,
                    aql14: null,
                    aql15: null,
                    aql16: null,
                    aql17: null,
                    aql18: null,
                    aql19: null,
                    aql20: null,
                    aql21: null,
                    aql22: null,
                    aql23: null,
                    aql24: null,
                    aql25: null,
                    aql26: null
                },
                // 表单参数
                form: { },
                // 表单校验
                rules: {}
            };
        },
        created() {
            this.getList();
        },
        methods: {
            /** 查询抽样规则-接收质量限列表 */
            getList() {
                this.loading = true;
                listAql(this.queryParams).then(response => {
                    this.aqlList = response.rows;
                    this.total = response.total;
                    this.loading = false;
                });
            },
            // 取消按钮
            cancel() {
                this.open = false;
                this.openCode = false;
                this.reset();
            },
            // 表单重置
            reset() {
                this.form = {
                        id: null,
                        sampleCode: null,
                        sampleAql: null,
                        attr1: null,
                        createBy: null,
                        createTime: null,
                        updateBy: null,
                        updateTime: null,
                        factoryCode: null,
                        delFlag: null,
                        maxBadQuality: null,
                        checkType: null,
                        typeCode: null,
                        aql1: null,
                        aql2: null,
                        aql3: null,
                        aql4: null,
                        aql5: null,
                        aql6: null,
                        aql7: null,
                        aql8: null,
                        aql9: null,
                        aql10: null,
                        aql11: null,
                        aql12: null,
                        aql13: null,
                        aql14: null,
                        aql15: null,
                        aql16: null,
                        aql17: null,
                        aql18: null,
                        aql19: null,
                        aql20: null,
                        aql21: null,
                        aql22: null,
                        aql23: null,
                        aql24: null,
                        aql25: null,
                        aql26: null
                };
                this.resetForm("form");
            },
            /** 搜索按钮操作 */
            handleQuery() {
                this.queryParams.pageNum = 1;
                this.getList();
            },
            /** 重置按钮操作 */
            resetQuery() {
                this.resetForm("queryForm");
                this.handleQuery();
            },
            // 多选框选中数据
            handleSelectionChange(selection) {
                this.ids = selection.map(item => item.id)
                this.single = selection.length !== 1
                this.multiple = !selection.length
            },
            /** 新增按钮操作 */
            handleAdd() {
                this.reset();
                this.open = true;
                this.title = "添加抽样规则-接收质量限";
            },
            /** 修改按钮操作 */
            handleUpdate(row) {
                this.reset();
                const id = row.id || this.ids
                getAql(id).then(response => {
                    this.form = response.data;
                    this.open = true;
                    this.title = "修改抽样规则-接收质量限";
                });
            },
            /** 维护样本量按钮操作 */
            handleUpdateCode() {
                this.openCode = true;
            },
            /** 提交按钮 */
            submitForm() {
               
            },
            /** 删除按钮操作 */
            handleDelete(row) {
               
            },
            /** 导出按钮操作 */
            handleExport() {

            }
        }
    }
</script>
