<template>
    <div class="main-contain">
        <div class="position">
            <bread-crumb :crumbs='crumbs'></bread-crumb>
        </div>
        <div class="app-container">
            <div class="cell clearfix">
                <el-input style="width: 180px;" @keyup.enter.native='searchAction' v-model.trim="search_input" class="filter-item"/>
                <el-button style="margin-right:10px;" class="filter-item" type="primary" icon="el-icon-search" @click="searchAction">搜索</el-button>
                <el-date-picker
                v-model="value1"
                @change="changeTime"
                style="margin-right:10px;"
                type="daterange"
                range-separator="-"
                start-placeholder="开始日期"
                end-placeholder="结束日期">
                </el-date-picker>
                <!-- <label class="title"><span class="name">挂号类型</span> : </label>
                <el-select v-model="value" placeholder="请选择" style="width:150px;">
                    <el-option
                    v-for="item in options"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                    </el-option>
                </el-select> -->
            </div>
            <el-table :data="tableData" border style="width: 100%;" :row-style="{ color: '#303133' }" :header-cell-style="{backgroundColor: 'rgb(245, 247, 250)',color: '#606266'}" highlight-current-row>
                <el-table-column align="center" type="index" label="序号" width="60">
                </el-table-column>
                <el-table-column align="center" prop="name" label="时间" width="100">
                    <template slot-scope="scope">{{ scope.row.create_time }}</template>
                </el-table-column>
                <el-table-column align="center" prop="dialysis_no" label="姓名" width="80">
                    <template slot-scope="scope">{{scope.row.name }}</template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="科室" width="80">
                    <template slot-scope="scope">{{ scope.row.department }}</template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="挂号类型" width="90">
                    <template slot-scope="scope">
                        <span v-if="scope.row.register == 1">普通</span>
                        <span v-if="scope.row.register == 2">主治</span>
                        <span v-if="scope.row.register == 3">主任</span>
                        <span v-if="scope.row.register == 4">免收诊金</span>
                        <span v-if="scope.row.register == 5">专家</span>
                    </template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="就诊号" width="80">
                    <template slot-scope="scope"></template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="证件号">
                    <template slot-scope="scope">{{ scope.row.idCard }}</template>
                </el-table-column>
                <el-table-column align="center" label="患者保险类型" width="80">
                    <!-- <template slot-scope="scope">{{ scope.row.name }}</template> -->
                </el-table-column>
                <el-table-column align="center" prop="name" label="医生" width="80">
                    <template slot-scope="scope">{{ scope.row.doctor }}</template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="挂号费" width="70">
                    <template slot-scope="scope">{{ scope.row.registrationFee }}</template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="诊疗费" width="70">
                    <template slot-scope="scope">{{ scope.row.medicalExpenses }}</template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="工本费" width="70">
                    <template slot-scope="scope">{{ scope.row.cost }}</template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="操作人" width="70">
                    <template slot-scope="scope">{{ $store.getters.xt_user.org.org_name }}</template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="操作" width="80">
                    <template slot-scope="scope">
                        <!-- <el-button size="mini" type="primary">编辑</el-button> -->
                        <span>已就诊</span>
                    </template>
                </el-table-column>
            </el-table>

            <!-- <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :page-sizes="[10, 50, 100]"
                :page-size="10"
                background
                style="margin-top:20px;float: right"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total"
            >
            </el-pagination> -->
        </div>
    </div>
</template>

<script>
const moment = require('moment')
import BreadCrumb from '@/xt_pages/components/bread-crumb'
export default {
    components:{
        BreadCrumb
    },
    data(){
        return{
            crumbs: [
                { path: false, name: '门诊挂号' },
                { path: false, name: '挂号历史' }
            ],
            search_input:'',
            value1:'',
            tableData: []
        }
    },
    created(){
        let a = JSON.parse(localStorage.getItem("temp"))
        let arr = []
        a.map(item => {
            if(item.org_id == this.$store.getters.xt_user.org_id){
                item.create_time = moment(item.create_time * 1000).format('YYYY-MM-DD')
                arr.push(item)
            }
            
        })
        console.log('aaaaaaaaaaaaaa',a)
        this.tableData = arr
    },
    methods:{
        searchAction(){
            let arr = this.tableData
            let a = []
            arr.map(item => {
                if(item.name.indexOf(this.search_input) > -1 && item.org_id == this.$store.getters.xt_user.org_id){
                    a.push(item)
                }
            })
            this.tableData = a
        },
        changeTime(val){
            let arr = JSON.parse(localStorage.getItem("temp"))
            arr.map(item => {
                item.create_time = moment(item.create_time * 1000).format('YYYY-MM-DD')
            })
            this.tableData = arr
            console.log(new Date(val[0]).getTime() / 1000)
            console.log(new Date(val[1]).getTime() / 1000)
            let arr1 = this.tableData
            let a = []
            arr1.map(item => {
                // if(new Date(val[0]).getTime() / 1000){
                //     a.push(item)
                // }
                if(new Date(item.create_time).getTime() / 1000 > new Date(val[0]).getTime() / 1000 && new Date(item.create_time).getTime() / 1000 < new Date(val[1]).getTime() / 1000 && item.org_id == this.$store.getters.xt_user.org_id){
                    a.push(item)
                }
            })
            this.tableData = a
        }

    }
}
</script>

<style lang="scss" scoped>
</style>
