<template>
<div class="examination secondApprove">
    <div class="common-head-search">
        <el-form :inline="true">
            <el-form-item label='标样编号'>
                <el-input v-model="search.stuffNoUser" size="small" placeholder="请输入标样编号" style="width: 150px;"></el-input>
            </el-form-item>
            <el-form-item label='标样名称'>
                <el-input v-model="search.stuffName" size="small" placeholder="请输入标样编号" style="width: 150px;"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button icon="el-icon-search" type="goon" size="mini" :loading='dataLoading' @click="mainData">查询</el-button>
                <el-button icon="el-icon-refresh" type="info" plain size="mini" @click="reset">重置</el-button>

                <el-button icon="el-icon-search" type="goon" size="mini" :loading='dataLoading' @click="searchAnlyName">元素查询</el-button>
            </el-form-item>
        </el-form>
    </div>
    <div>
        <div class="common-title-div">
            <div class="common-title-name">
                <img style="width: 25px; height: 25px" src='../../../../assets/img/imgScreen/logo.png' />
                标样信息
            </div>
        </div>
        <div class="common-table-div" id="topTable">
            <el-table
                ref="el_table_1"
                border
                :height="singleTableHeight"
                width = "100%"
                highlight-current-row
                :data="table.list1"
            >
                <el-table-column sortable show-overflow-tooltip align="center" width="120" prop="STUFF_NAME" label="标样名称"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" width="160" prop="STUFF_NO_USER" label="标样编号"></el-table-column>
                <template v-for="col in cols">
                    <el-table-column
                        :prop="col.ANLY_ITEM_NO"
                        show-overflow-tooltip
                        align="center"
                        :key="col.ANLY_ITEM_NO"
                        :label="col.ANLY_ITEM_NAME + '(' + col.UNIT_NAME + ')'"
                    >
                    </el-table-column>
                </template>
            </el-table>
        </div>
        <div class="common-foot-style">
            <el-pagination @size-change="pageSizeChange" @current-change="pageCurrentChange"
                :current-page="page.pageNum" :page-sizes="[50, 100, 200, 500, 1000]" :page-size="page.pageSize" layout="total, sizes, prev, pager, next, jumper"
                :total="page.totalPage" background>
            </el-pagination>
        </div>
    </div>
     <el-dialog
      :close-on-click-modal="false"
      @close="closebatch"
      width="100%"
      :visible.sync="recallShow"
      top="0"
    >
      <div slot="title" class="titleBox">
        <i class="el-icon-document" style="font-size: 20px"></i>
        <span style="margin-left: 10px; font-size: 18px">元素查询</span>
      </div>
      <div style="float: right;">
          <el-form :inline="true">
            <el-form-item label='选择元素'>
                <el-select
                    v-model="element"
                    clearable
                    multiple
                    style="width: 100%;height: 28px"
                    filterable
                    collapse-tags
                    size="small"
                >
                    <el-option
                    v-for="(item, index) in elementType"
                    :key="index"
                    :label="item.ANLY_ITEM_NAME"
                    :value="item.ANLY_ITEM_NO"
                    >
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button icon="el-icon-search" type="goon" size="mini" @click="searchYuansu">查询</el-button>
            </el-form-item>
        </el-form>
      </div>
      <div class="common-table-div">
        <el-table
          v-loading="tableLoading5"
          border
          :height="theight5"
          highlight-current-row
          :data="tableData5"
          :icore-filter-flag="icoreFilterFlag"
          :header-cell-style="tableHeaderCellStyle"
        >
                <el-table-column sortable show-overflow-tooltip align="center" width="120" prop="STUFF_NAME" label="标样名称"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" width="160" prop="STUFF_NO_USER" label="标样编号"></el-table-column>
                <template v-for="col in cols2">
                    <el-table-column
                        :prop="col.ANLY_ITEM_NO"
                        show-overflow-tooltip
                        align="center"
                        :key="col.ANLY_ITEM_NO"
                        :label="col.ANLY_ITEM_NAME"
                    >
                    </el-table-column>
                </template>
        </el-table>
      </div>
    </el-dialog>
</div>
</template>
<script>
import {Cookie,formatDate} from '@/utils/util.js';
import {cookieUserId, cookieUserName} from '@/config/config.js';
// let userName = getCookie(cookieUserName);
// let userId = getCookie(cookieUserId);
export default {
    data () {
        return {
            search: {
                stuffNoUser:'',
                stuffName: ''
            },
            dataLoading: false,
            tableList:{},
            recallShow: false,
            theight5: 0,
            tableData5:[],
            tableLoading5: false,
            element: [],
            elementType: [],
            table: {
                list1:[]
            },
            page: {
                pageNum: 1,
                pageSize: 100,
                totalPage: 0
            },
            cols: ['无'],
            cols2: ['无'],
            singleTableHeight: 600,
            icoreFilterFlag: true,
            tableExportLoading: false,
        }
    },
    created() {
        this.singleTableHeight = window.innerHeight - 190
        let aaa = new Date()
        let bbb =  new Date().getTime() -60000*60*24*7;
        aaa.setTime(bbb);
        this.theight5 = window.innerHeight - 230 < 249 ? 249 : window.innerHeight - 230
        this.search.stateTime =  [this.getYNM(new Date()), this.getYNM(new Date())]
    },
    mounted() {
    },
    methods: {
        getYNM(date) {
            let year = date.getFullYear().toString();
            let month = date.getMonth() + 1;
            let day = date.getDate();
            month = month < 10 ? "0" + month : month;
            day = day < 10 ? "0" + day : day;
            return `${year}-${month}-${day}`;
        },
        mainData(){
            this.page.pageNum = 1;
            this.page.pageSize = 100
            this.searchData()
        },
        searchData() {
            let obj ={
                stuffNoUser: this.search.stuffNoUser,
                stuffName: this.search.stuffName,
                pageIndex: this.page.pageNum,
                pageSize: this.page.pageSize,
                validFlag: 1
            }
            this.dataLoading = true
            this.axios.post('pass/baseManagement/v1/limslrcstuffs/queryLimsLrcStuffByInfo', obj, { individualType: 'json' }).then(res => {
                if (res.code == 0 || res.code == 200) {
                    if(res.data.head[0] != null){
                        this.cols = res.data.head
                    }
                    this.table.list1 = res.data.badyData.list
                    this.page.totalPage = res.data.badyData.total
                } else {
                    this.$message.error(res.message)
                }
                this.dataLoading = false;
            }).catch(err => {
                this.dataLoading = false;
                this.$message.error(err.message)
            })
        },
        searchAnlyName(){
            this.recallShow = true;
            let obj ={
            }
            this.axios.post('pass/baseManagement/v1/limslrcstuffs/queryLimsLrcStuffByAnlyName', obj, { individualType: 'json' }).then(res => {
                if (res.code == 0 || res.code == 200) {
                    this.elementType = res.data
                } else {
                    this.$message.error(res.message)
                }
                this.dataLoading = false;
            }).catch(err => {
                this.dataLoading = false;
                this.$message.error(err.message)
            })
        },
        searchYuansu(){
            let obj ={
                pageIndex: 1,
                pageSize: 999,
                list: this.element,
                list1: this.elementType,
                validFlag: 1
            }
            this.dataLoading = true
            this.axios.post('pass/baseManagement/v1/limslrcstuffs/queryLimsLrcStuffByInfoByYuanSu', obj, { individualType: 'json' }).then(res => {
                if (res.code == 0 || res.code == 200) {
                    if(res.data.head[0] != null){
                        this.cols2 = res.data.head
                    }
                    this.tableData5 = res.data.badyData.list
                } else {
                    this.$message.error(res.message)
                }
                this.dataLoading = false;
            }).catch(err => {
                this.dataLoading = false;
                this.$message.error(err.message)
            })
        },
        closebatch(){

        },
        handleCurrentChange(row){
            this.tableList = row
            this.searchData();
        },
        tableHeaderCellStyle () {
            return 'color: rgb(255,255,255);border-bottom: 1px solid #DCDFE7;'
        },
        pageSizeChange (size) {
            this.page.pageSize = size;
            this.searchData();
        },
        pageCurrentChange (index) {
            this.page.pageNum = index;
            this.searchData();
        },
        reset() {
            this.search.matName = '';
            let aaa = new Date()
            let bbb =  new Date().getTime() -60000*60*24*7;
            aaa.setTime(bbb);
            this.search.stateTime =  [this.getYNM(aaa), this.getYNM(new Date())]
        },
    }
}
</script>
<style  scoped>
</style>

