{
    template: '${tmpl}',
    data: function () {
        var validMethod = (rule, value, callback) => {
            return this.validfileds(rule, value, callback);
        };

        return {
            statustab: "1",
            uploadResult: "",
            showImport:false,
            fileurl:"",
            datalist : [],

            showDetail:false,
            applyStatusList:[],
            identityTypeList:[],
            eduTypeList:[],
            search: {
                list: [],
                currentPage: 1,
                pageSize: 20,
                total : 0,
                userName: '',
                mobile: '',
                identityType: '',
                sex:'',
                edu: '',
                age: '',
            },
            applyDetail: {
                id: '',
                eaccount: {},
            },
            search2: {
                list: [],
                currentPage: 1,
                pageSize: 20,
                total : 0,
                userName: '',
                mobile: '',
                identityType: '',
                personsSign:'',
                edu: '',
                bankno: '',
            },
        }
    },
    mounted: function () {
        this.getApplyStatusList();
        this.getIdentityTypeList();
        this.getEduTypeList();
        this.resetSearch();
        this.resetSearch2();
    },
    created: function () {
    },
    methods: {
        statusChange(v) {
        },
        getApplyStatusList() {
            var self = this;
            this.$root.getReq("/web/metaCtl/getDicConfig",{"dicKey": "applyStatus"}).then(cfg=>{
                self.applyStatusList = [];
                Object.keys(cfg.data).forEach(key=>{
                    self.applyStatusList.push({"label":cfg.data[key],"value":key});
                });
            });
        },
        getIdentityTypeList() {
            var self = this;
            this.$root.getReq("/web/metaCtl/getDicConfig",{"dicKey": "identityType"}).then(cfg=>{
                self.identityTypeList = [];
                Object.keys(cfg.data).forEach(key=>{
                    self.identityTypeList.push({"label":cfg.data[key],"value":key});
                });
            });
        },
        getEduTypeList() {
            var self = this;
            this.$root.getReq("/web/metaCtl/getDicConfig",{"dicKey": "eduType"}).then(cfg=>{
                self.eduTypeList = [];
                Object.keys(cfg.data).forEach(key=>{
                    self.eduTypeList.push({"label":cfg.data[key],"value":key});
                });
            });
        },
        getEmptySearch() {
            return {
                list: [],
                currentPage: 1,
                pageSize: 20,
                total : 0,
                userName: '',
                mobile: '',
                identityType: '',
                sex:'',
                edu: '',
                age: '',
            }
        },
        resetSearch() {
            this.search = this.getEmptySearch();
            this.getList();
        },
        tableHeaderColor({ row, column, rowIndex, columnIndex }) {
            if (rowIndex === 0) {
                return 'background-color: #F5F5F5;color: #2F2F2F;font-size: 14px;font-weight:400;'
            }
        },
        opSearch() {
            this.getList();
        },
        getList() {
            var self = this;
            this.$root.postReq("/web/ejobapplyCtl/allApplys", {
                search: this.getParams()
            }).then(function (d) {
                if (d.status == 0) {
                    self.search.list = d.data.rows || [];
                    self.search.total = d.data.count || 0;
                } else {
                }
            });
        },
        getParams() {
            var params = {};
            for(var f in this.search) {
                if(f == "list") {
                    continue;
                }
                params[f] = this.search[f];
            }
            return params;
        },
        onColFormater(row, column, cellValue, index) {
            return cellValue || "---";
        },

        handleSizeChange(val) {
            this.search.pageSize = val;
            this.resetSearch();
        },
        handleCurrentChange(val) {
            this.search.currentPage = val;
            this.getList();
        },
        validfileds(rule, value, callback) {
            return callback();
        },
        openDetail(item) {
            this.applyDetail = item;
            this.showDetail = true;
        },
        getEmptySearch2() {
            return {
                list: [],
                currentPage: 1,
                pageSize: 20,
                total : 0,
                userName: '',
                mobile: '',
                identityType: '',
                personsSign:'',
                edu: '',
                bankno: '',
            }
        },
        resetSearch2() {
            this.search2 = this.getEmptySearch2();
            this.getList2();
        },
        opSearch2() {
            this.getList2();
        },
        getList2() {
            var self = this;
            this.$root.postReq("/web/ejobrosterCtl/list", {
                search: this.getParams2()
            }).then(function (d) {
                if (d.status == 0) {
                    self.search2.list = d.data.rows || [];
                    self.search2.total = d.data.count || 0;
                } else {
                }
            });
        },
        getParams2() {
            var params = {};
            for(var f in this.search2) {
                if(f == "list") {
                    continue;
                }
                params[f] = this.search2[f];
            }
            return params;
        },
        handleSizeChange2(val) {
            this.search2.pageSize = val;
            this.resetSearch2();
        },
        handleCurrentChange2(val) {
            this.search2.currentPage = val;
            this.getList2();
        },
        showImportDialog() {
            this.showImport = true;
        },
        uploadsuccess(v) {
            if(!v || !v[0] || !v[0].url) {
                this.$message.warning("提交成功");
                return;
            }

            this.fileurl = v[0].url;
            this.parseExcel();
        },
        parseExcel() {
            var self = this;
            const loading = this.$loading({
                lock: true,
                text: '正在努力解析excel',
                spinner: 'el-icon-loading',
                background: 'rgba(0, 0, 0, 0.7)'
            });
            self.$root.postReq("/web/ejobrosterCtl/parseRoster", {
                url: self.fileurl
            }).then(function (d) {
                loading.close();
                if (d.status == 0) {
                    self.datalist = d.data || [];
                } else {
                    self.$alert(d.msg || "文件解析失败", '提示', {
                        confirmButtonText: '确定',
                        callback: action => {}
                    });
                }
            });
        },
        saveRoster() {
            var self = this;
            const loading = this.$loading({
                lock: true,
                text: '正在努力保存名单，请稍候',
                spinner: 'el-icon-loading',
                background: 'rgba(0, 0, 0, 0.7)'
            });
            self.$root.postReq("/web/ejobrosterCtl/saveRoster", {
                url: self.fileurl
            }).then(function (d) {
                loading.close();
                if (d.status == 0) {
                    self.$message.success("保存成功");
                    self.resetSearch2();
                } else {
                    self.$alert(d.msg || "保存失败", '提示', {
                        confirmButtonText: '确定',
                        callback: action => {}
                    });
                }
            });
        },
    },
    vname: "gsb-eallapplys"
}