import '../../../scripts/bootstrap/js/bootstrap.min'
import '../../../scripts/jquerybigautocomplet/jquery.bigautocomplete'
import '../../../scripts/jquerybigautocomplet/jquery.bigautocomplete.css'
import {tp, clickFn as cFn, aj, msg, jsonToStr as jts} from '../../comm-util/comm'

cd_show(0, 9);
//自动补齐
const com = $("#company");
com.bigAutocomplete({
    width: com.width() + 20,
    url: con.auto_aj,
    callback: function (data) {
        con.autoFn(data);
    }
});
///第二个自动补齐
const com2 = $("#comp2");
com2.bigAutocomplete({
    width: com2.width() + 20,
    url: con.auto_aj,
    callback: function (data) {
        con.autoFn2(data);
    }
});

//专业查询
cFn('.zhan-cha', function (e) {
    let v = $("#comp2").val();
    if (v.length) {
        aj({url: con.zhuan_cha + v, fn: con.zc_fn})
    } else {
        msg('请输入名称！');
    }
});
//第二个查询按钮s
let obj;
cFn('.er-cha', function () {
    obj = {
        zhuan: $('comp2').val(),
        cy: $('#sel-add').val(),
        nian: $('#sel-nian').val(),
        di: $('#di-id').val(),
        gao: $('#gao-id').val(),
        page: 1
    };
    aj({
        url: con.er_cha + "?obj=" + jts(obj),
        fn: con.erFn
    })
});

$('#fenye_id').jqPaginator({
    totalPages: 100,
    visiblePages: 8,
    currentPage: 1,
    first: '<li class="first"><a href="javascript:void(0);">首页<\/a><\/li>',
    prev: '<li class="prev"><a href="javascript:void(0);"><i class="arrow arrow2"><\/i>上一页<\/a><\/li>',
    next: '<li class="next"><a href="javascript:void(0);">下一页<i class="arrow arrow3"><\/i><\/a><\/li>',
    last: '<li class="last"><a href="javascript:void(0);">末页<\/a><\/li>',
    page: '<li class="page"><a href="javascript:void(0);">{{page}}<\/a><\/li>',
    onPageChange: function (num, type) {
        //响应参数变化
        if (type !== 'init') {
            obj.page = num;
            aj({
                url: con.er_cha + "?obj=" + jts(obj),
                fn: con.erFn
            });
        }
    }
});
//第三个查询联动
$('#sel-zyxk').parent().parent().find('li').click(function (e) {
    let t = e.target;
    let id = $(t).attr('data-val');
    aj({
        url: con.san_aj+'?id='+id, fn: function (data) {
            con.san_fn(data)
        }
    })
});
//第三个查询联动3
$('#sel-zyfl').parent().parent().on('click','li',function (e) {
    let t = e.target;
    let id = $(t).attr('data-val');
    aj({
        url: con.san_aj2+'?id='+id, fn: function (data) {
            con.san_fn2(data)
        }
    })
});
//第三个查询
cFn('.san_cha', function () {
    let ob = {
        ke1: $('#sel-zyxk').val(),
        ke2: $('#sel-zyfl').val(),
        ke3: $('#sel-zymc').val(),
        id1: $('#sel-zyxk').attr('data-val'),
        id2: $('#sel-zyfl').attr('data-val'),
        id3: $('#sel-zymc').attr('data-val'),
    };
    con.san_cha(ob);
});

//myselect选择事件
$('.js-my-select').find('.option-c>ul').on('click','li',function () {
    $(this).parent().find('.selected').removeClass('selected');
    $(this).parent().parent().find('.selected').removeClass('selected');
    $(this).addClass('selected');
    $(this).parent().parent().parent().find('samp.init-c').text($(this).text());
    $(this).parent().parent().parent().find('input:hidden').val($(this).text()).attr('data-val', $(this).attr('data-val'));
});
//加减事件v
let mouse_timeout;
let nun_timeout;
$('.js-jian').click(function () {
    $(this).next().val(parseInt($(this).next().val()) - 1);
}).mousedown(function () {
    let x = parseInt($(this).next().val());
    let _this = $(this).next();
    mouse_timeout = setTimeout(function () {
        nun_timeout = setInterval(function () {
            x = x - 1;
            _this.val(x);
        }, 30);
    }, 400);
}).mouseup(function () {
    clearTimeout(nun_timeout);
    clearTimeout(mouse_timeout);
});
$('.js-jia').click(function () {
    $(this).prev().val(parseInt($(this).prev().val()) + 1);
}).mousedown(function () {
    let x = parseInt($(this).prev().val());
    let _this = $(this).prev();
    mouse_timeout = setTimeout(function () {
        nun_timeout = setInterval(function () {
            x = x + 1;
            _this.val(x);
        }, 50);
    }, 400);
}).mouseup(function () {
    clearTimeout(nun_timeout);
    clearTimeout(mouse_timeout);
});