<template>
    <el-container>
        <el-header>
            <div class="left-panel">
                <el-button type="primary" icon="el-icon-plus" @click="add">新增</el-button>
                <!-- <el-button type="primary" icon="el-icon-top" @click="importInspect">上传</el-button> -->
            </div>
            <div class="right-panel">
                <el-date-picker
                    v-model="query.test_date"
                    type="date"
                    value-format="YYYY-MM-DD"
                />
                <el-button
                    type="primary"
                    icon="el-icon-search"
                    @click="handleQuery"
                >查询</el-button>
            </div>
        </el-header>
        <el-main class="nopadding">
            <el-tabs v-model="activeId" class="demo-tabs" @tab-click="handleClick" type="card">
                <el-tab-pane v-for="item in behaviors" v-bind:key="item.id" :label="item.name" :name="item.id">
                </el-tab-pane>
            </el-tabs>
            <!-- <el-radio-group v-model="radio1" class="ml-4">
                <el-radio
                    v-for="item in behaviors"
                    :key="item.id"
                    :label="item.id" 
                    size="large"
                >
                    {{ item.name }}
                </el-radio>
            </el-radio-group> -->
            <scTable
                ref="table"
                :data="tableData"
                :apiObj="apiObj"
                row-key="id"
                stripe
                :height="600"
                :params="query"
            >
                <el-table-column type="index" width="50"/>
                <el-table-column label="实验日期" prop="test_date" show-overflow-tooltip>
                </el-table-column>
                <el-table-column label="样品编号" prop="sample_number">
                </el-table-column>
                <el-table-column label="样品厚度/mm" prop="val_hd" v-if="activeName=='透过率'">
                </el-table-column>
                <el-table-column label="型号规格" prop="specification" v-if="activeName=='中温粘度'||activeName=='膨胀'">
                </el-table-column>
                <el-table-column label="样品数量" prop="sample_count" v-if="activeName=='析晶'">
                </el-table-column>
                <el-table-column label="样品密度" prop="sample_density" v-if="activeName=='高温粘度'">
                </el-table-column>
                <el-table-column label="检验员" prop="test_user" show-overflow-tooltip>
                </el-table-column>
                <el-table-column label="实验温度及保温时间" prop="sample_number" v-if="activeName=='析晶'">
                </el-table-column>
                <el-table-column label="升至最高温度/℃" prop="val_zgwd" v-if="activeName=='高温粘度'">
                </el-table-column>
                <el-table-column label="仪器状态" prop="factory" show-overflow-tooltip>
                    <template #default="scope">
                        <el-tag>{{ state_[scope.row.equip_state] }}</el-tag>
                    </template>
                </el-table-column>
                <el-table-column label="折射率(589nm)" prop="val_zsl" v-if="activeName=='折射率'">
                </el-table-column>
                <el-table-column label="透过率(550nm)" prop="val_tgl" v-if="activeName=='透过率'">
                </el-table-column>
                <el-table-column label="Ts/℃" prop="val_ts" v-if="activeName=='中温粘度'">
                </el-table-column>
                <el-table-column label="30-300℃膨胀系数" prop="val_pzxs" v-if="activeName=='膨胀'">
                </el-table-column>
                <el-table-column label="Tg/℃" prop="val_tg" v-if="activeName=='膨胀'">
                </el-table-column>
                <el-table-column label="Tf/℃" prop="val_tf" v-if="activeName=='膨胀'">
                </el-table-column>
                <el-table-column label="析晶" prop="val_xj" v-if="activeName=='析晶'">
                    <template #default="scope">
                        <el-tag>{{ state_xj[scope.row.val_xj] }}</el-tag>
                    </template>
                </el-table-column>
                <el-table-column label="操作" fixed="right" width="150">
                    <template #default="scope">
                        <el-link type="primary" @click="table_show(scope.row)">查看</el-link>
                        <el-divider direction="vertical"></el-divider>
                        <el-link type="danger" @click="table_del(scope.row)">删除</el-link>
                    </template>
                </el-table-column>
            </scTable>
        </el-main>
        <save-dialog v-if="visible" ref="saveDialog" :activeName="activeName" :activeId="activeId"
            @success="handleSuccess" @closed="visible = false">
        </save-dialog>
        <!-- <el-dialog
            title="上传"
            destroy-on-close
            v-model="visible"
            @closed="visible = false"
        >
            <el-form ref="dialogForm" :model="form" :rules="rules" label-width="120px">
                <el-form-item label="模板文件">
                    <el-link href="" target="_blank" type="primary" style="margin-right:10px">模板一</el-link>
                    <el-link href="" target="_blank" type="primary">模板二</el-link>
                </el-form-item>
                <el-form-item label="上传文件">
                    <span>{{ form.fileName }}</span>
                    <sc-upload-file
                        v-model="form.file"
                        :multiple="false"
                        :limit="1"
                        accept="xlsx"
                        tip="文件不要超过10M,请上传xlsx格式文件"
                        >
                        <el-button type="primary" icon="el-icon-upload"
                            >上传</el-button
                        >
                    </sc-upload-file>
                </el-form-item>
            </el-form>
            <el-footer>
                <el-button type="primary" :loading="isSaveing" @click="submitFile">提交</el-button>
                <el-button @click="visible = false">取消</el-button>
            </el-footer>
        </el-dialog> -->
    </el-container>
</template>
<script>
import saveDialog from './behavior_form.vue';
    export default {
        name: "rparty",
        components:{ saveDialog },
        data() {
            return {
                apiObj: this.$API.qm.ptest.list,
                query: {
                    testitem:'3442815297965547520',
                    test_date:''
                },
                state_:{
                    'R':'正常',
                    'T':'异常'
                },
                state_xj:{
                    'S':'析晶',
                    'K':'不析晶',
                    'θ':'未化'
                },
                form:{
                    file:'',
                    fileName:'',
                },
                rules: {
                    file:[{required:true, message:'请上传上传文件', trigger: "blur"}]
                },
                activeId:'3442815297965547520',
                activeName:'折射率',
                visible:false,
                isSaveing:false,
                selection: [],
                behaviors:[],
                tableData:[],
            };
        },
        mounted(){
            this.getTextItem();
        },
        methods: {
            //获取检验项目
            getTextItem(){
                let that = this;
                that.$API.qm.getTestItem.get({tag:'behavior',page:0}).then(res=>{
                    that.behaviors = res;
                })
            },
            handleClick(val){
                this.activeId = val.props.name;
                this.activeName = val.props.label;
                this.query.testitem = val.props.name;
                this.$refs.table.refresh();
            },
            add(){
                this.visible = true;
                this.$nextTick(() => {
                    this.$refs.saveDialog.open("add");
                });
            },
            importInspect(){
                this.visible = true;
            },
            submitFile(){

            },
            closeVisible(){
                this.visible = false;
            },
            handleSuccess(){
                this.visible = false;
                this.$refs.table.refresh();
            },
            //查看
            table_show(row) {
                
            },
            handleQuery() {
                this.$refs.table.queryData(this.query)
            },
            resetQuery() {
                this.query = {};
            },
        },
    };
</script>