<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="widtd=device-widtd, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/static/css/css.css">
    <link rel="stylesheet" type="text/css" href="/static/css/iefilemaintaindetail.css">
    <link rel="stylesheet" type="text/css" href="/static/css/bootstrap-select.min.css">
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/bootstrap.min.js"></script>
    <script src="/static/js/vue-2.4.0.js"></script>
    <script src="/static/js/axios.min.js"></script>
    <script src="/static/js/vue-Cookies.js"></script>
    <script type="text/javascript" src="/static/js/jquery.select.js"></script>

    <script src="/static/js/bootstrap-select_new.js"></script>
    <!-- 图标js -->
    <!-- <script src="/static/js/ionicons.js"></script> -->

    <title>Document</title>
</head>

<body>
    <div id="app">
        <div class="navbar navbar-default">
            <div class="container">
                <!-- navbar-header用于设置内容横向显示 -->
                <div class="navbar-header">
                    <a href="/index" class="navbar-brand"></a>
                </div>
                <!-- navbar-nav用来设置横向显示 -->
                <!-- navbar-right用来设置右浮动 -->
                <!-- hidden-xs用于当屏幕很小的情况下隐藏div里面的内容 -->
                <div class="hidden-xs">
                    <ul class="nav navbar-nav">
                        <li class="dropdown">
                            <!--订单一览表-->
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                订单一览表
                                <b class="caret"></b>
                            </a>
                            <ul class="nav dropdown-menu">
                                <li><a href="/index">订单一览表</a></li>
                            </ul>
                        </li>
                        <li class="dropdown">
                            <!--月度产能评估表-->
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                月度产能评估表
                                <b class="caret"></b>
                            </a>
                            <ul class="nav dropdown-menu">
                                <li><a href="/depps">月度产能评估表</a></li>
                                <li><a href="/dessettingtm">车间标准产能设置</a></li>
                            </ul>
                        </li>
                        <li class="dropdown">
                            <!--月度主排程计划-->
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                月度主排程计划
                                <b class="caret"></b>
                            </a>
                            <ul class="nav dropdown-menu">
                                <li><a href="/depps">计划主交期</a></li>
                                <li><a href="#">计划部门交期</a></li>
                            </ul>
                        </li>
                        <li class="dropdown">
                            <!--ie文件号管理-->
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                IE工艺文件号管理
                                <b class="caret"></b>
                            </a>
                            <ul class="nav dropdown-menu">
                                <li><a href="/iefiletm">新增IE工艺文件号</a></li>
                                <li><a href="/iefilemaintaintm">IE工艺文件号维护</a></li>
                                <li><a href="/iefilemaintaindetailtm">IE效率明细表</a></li>
                                <li><a href="/iefilemaintaininfotm">IE效率统计表</a></li>
                            </ul>
                        </li>
                    </ul>
                    <ul class="nav navbar-nav navbar-right">
                        <li v-if="username !=''">
                            <a>{% verbatim %}{{ '欢迎'+username+'！！！' }} {% endverbatim %}</a>
                        </li>
                        <li v-else><a href="">请登录</a></li>
                        <li><a href="/login/" @click="logout()">退出登录</a></li>
                    </ul>
                </div>
            </div>
        </div>
        <!--表头-->
        <div class="filter">
            <div class="container ">
                <label>
                    <div class="navbar-nav">日期：</div>

                    <div class="navbar-nav"><input type='date' class="input form-control" v-model='data_timeqi' /></div>
                </label>
                <label>
                    <div class="navbar-nav">至：</div>
                    <div class="navbar-nav"><input type='date' class="input form-control" v-model='data_timezhi' />
                    </div>
                </label>
                <label>
                    <div class="navbar-nav">车间：</div>
                    <div class="navbar-nav">
                        <input class="input form-control" id="erp_dep" type="text" autocomplete="off" />
                    </div>
                </label>
                <label>
                    <div class="navbar-nav">IE工艺文件号：</div>
                    <div class="navbar-nav">
                        <input class="input form-control" id="iefileno" type="text" autocomplete="off" />
                    </div>
                </label>
                <label>
                    <div class="navbar-nav">结案否：</div>
                    <div class="navbar-nav">
                        <select class="input form-control" v-model="cls_id">
                            <option value="1" selected="selected">全部</option>
                            <option value="2">结案</option>
                            <option value="3">未结案</option>
                        </select>
                    </div>
                </label>
                <label class="save def" @click="seek()">
                    <div class="btn btn-primary navbar-nav">查询</div>
                </label>
                <label class="save def">
                    <div class="btn btn-primary navbar-nav" @click="exportaa()">导出数据</div>
                </label>
            </div>
        </div>
        <div class="container">
            <table class="table table-hover">
                <tbody>
                    <tr v-for="(item,i) in seek_data" ::key="i">
                        <td v-if="i>0" v-text="i"></td>
                        <td v-else>行号</td>
                        <td v-text="item.gdmc_mb"></td>
                        <td v-text="item.prd_no"></td>
                        <td v-text="item.prd_name"></td>
                        <td v-text="item.so_no"></td>
                        <td v-text="item.zyxt_mb"></td>
                        <td v-text="item.dep_name"></td>
                        <td v-text="item.t_wh"></td>
                        <td v-text="item.t_qty"></td>
                        <td v-text="item.jjdj_mb"></td>
                        <td v-text="item.jj_up"></td>
                        <td v-text="item.mo_bc_qty"></td>
                        <td v-text="item.mo_ym_qty"></td>
                        <td v-text="item.cj_qty"></td>
                        <td v-text="item.job_time"></td>
                        <td v-text="item.file_serial"></td>
                        <td v-text="item.xxcn_t_mb"></td>
                        <td v-text="item.rjcn_t_mb"></td>
                        <td v-text="item.mo_cli_id"></td>
                        <td v-text="item.mo_no"></td>
                        <td v-text="item.mo_qty"></td>
                        <td v-text="item.ws__mo_qty"></td>
                        <td v-text="item.sh_mo_qty"></td>
                        <td v-text="item.dep_qty_sum"></td>
                        <td v-text="item.total_manpower"></td>
                        <td v-text="item.s_ie"></td>
                    </tr>
                </tbody>
            </table>
        </div>

    </div>
    <!-- 这里是导出数据 -->
    <script type="text/javascript" src="/static/js/export/exports.js"></script>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                data_timeqi: '',  //查询时间起
                data_timezhi: '',  //查询时间止
                username: '',  //登录用户名
                seek_data: [],  //查询到的数据
                cls_id:'1'   //结案否
            },
            mounted() {
                // 获取登录名
                // this.username=getCookie('username');
                this.username = $cookies.get('username')
                console.log($cookies.get('username'))
            },
            methods: {
                // 查询
                seek() {
                    var erp_dep = $('#erp_dep').val()
                    if(erp_dep.indexOf("->") != -1){
                        erp_dep = erp_dep.split("->")[0]
                    }
                    var iefileno = $('#iefileno').val()
                    if(iefileno.indexOf("->") != -1){
                        iefileno = iefileno.split("->")[0]
                    }
                    axios.get('/iefilemaintaindetail/', {
                        params: {
                            erp_dep: erp_dep,
                            iefileno: iefileno,
                            data_timeqi: this.data_timeqi,
                            data_timezhi: this.data_timezhi,
                            cls_id:this.cls_id
                        }
                    }).then(res => {
                        var data = res.data.data
                        this.seek_data = data
                        console.log(this.seek_data)
                    }).catch(err => {
                        alert(err.response["data"] + err.response["status"])
                    })
                },
                // 导出数据
                exportaa() {
                        // console.log(this.list)
                        var filter = [];
                        var title = [];
                        exportExcel(this.seek_data, 'IE效率明细表', title, filter);
                    },
                //获取当前日期
                addDate() {
                    var date = new Date();
                    var seperator1 = "-";
                    var year = date.getFullYear();
                    var month = date.getMonth() + 1;
                    var strDate = date.getDate();
                    if (month >= 1 && month <= 9) {
                        month = "0" + month;
                    }
                    if (strDate >= 0 && strDate <= 9) {
                        strDate = "0" + strDate;
                    }
                    var currentdate = year + seperator1 + month + seperator1 + strDate;
                    // console.log(currentdate)
                    this.data_timeqi = this.data_timezhi = currentdate
                },
                //退出登录
                logout() {
                    console.log("qweq")
                    axios.delete('/login/', {
                        params: {
                            user_1: this.user_1,
                            pswd: this.pswd,
                        }
                    })
                        .then(res => {

                        })
                        .catch(err => {
                        })

                },

            },
            created() {
                this.addDate()
            }
        });

        $(function () {
            // 开始写 jQuery 代码...
            var timer = null;
            // 定义一个公用的搜索接口
            // console.log(vm.$data.list)
            function getStr(n, url, field, clickif) {
                //n为搜索的参数 url为请求的路由，filed是定位表单的id,
                //clickif用于判断是否是第一次加载，如果不是第一次加载则需要模拟点击

                var search = n
                // 配置路由
                if (typeof search === 'undefined') {
                    search = ''
                };
                // console.log(search)
                axios.get(url, {
                    params: {
                        search_no: search
                    }
                })
                    .then(res => {
                        // alert(res.data)
                        var data1 = res.data.data
                        datas = data1
                        // console.log(datas)
                        if (datas.length == 0) {
                            alert("没有搜索到数据")
                            return
                        }
                        $.selectSuggest(field, datas);
                        // 是否第一次进入
                        if (clickif !== 1) {
                            $("#" + field).trigger("click");
                        }
                    })
                    .catch(err => {
                        Console.log(err.response)
                        alert(err.response["data"] + err.response["status"])
                    })
            };

            //查询部门资料调用
            $("#erp_dep").bind("input propertychange", function (event) {
                var search = $("#erp_dep").val()
                // console.log($("#testInput").val())
                timer && clearTimeout(timer);
                timer = setTimeout(function () {
                    getStr(search, '/dept/', 'erp_dep');

                }, 1000);
            });
            getStr('', '/dept/', 'erp_dep', 1);
            // 查询ie文件号
            $("#iefileno").bind("input propertychange", function (event) {
                var search = $("#iefileno").val()
                // console.log($("#testInput").val())
                timer && clearTimeout(timer);
                timer = setTimeout(function () {
                    getStr(search, '/iefileno/', 'iefileno');

                }, 1000);
            });
            getStr('', '/iefileno/', 'iefileno', 1);
        });
    </script>
    <!-- <script type="text/javascript" src="/static/js/export/jquery-1.8.2.js"></script> -->

</body>

</html>