选中数据显示右边

  • js:

    var product_name_sell_goods = []

    var flag_sell_goods = true

    var list_choose_sell_goods = ''

    function get_product_list_sell_goods() {

    // var product_name_table = ""

    var product_name_input = $("#workOrder_productRelaChoose_service_sell_goods").val().trim()

    var product_name_input_hidden = $("#workOrder_service_sell_goods_hidden").val().trim()

    // 点击叉叉删除对应一行数据

    var list_choose_sell_goods = product_name_input.split(",")

    var list_choose_sell_num = product_name_input_hidden.split(",")

    if(product_name_input.length != 0 && flag_sell_goods == true) {

    list_choose_sell_goods.forEach(function(val, i) {

    product_name_sell_goods.push({

    id: list_choose_sell_num[i],

    name: list_choose_sell_goods[i]

    })

    })

    // product_name_sell_goods = $(".product_choose_input_sell_goods").val().trim().split(",");

    flag_sell_goods = false

    }

    show_table_sell_goods(product_name_sell_goods)

    input_checked_sell_goods(product_name_sell_goods)

    }

    function input_checked_sell_goods(clients) {

    $("#table_products_sell_goods tbody input").prop("checked", false)

    clients.forEach(function(Cval, i) {

    if(product_name_sell_goods.indexOf(Cval) == -1) {

    product_name_sell_goods.push(Cval)

    }

    $("#table_products_sell_goods tbody tr").each(function(i, inputVal) {

    if($(inputVal).children("td:nth(2)").text() == Cval.name) {

    $(inputVal).children("td:nth(0)").children().prop("checked", true)

    }

    })

    })

    }

    function show_table_sell_goods(product_name_sell_goods) {

    var product_name_table_sell_goods = ""

    $.each(product_name_sell_goods, function(key, val) {

    product_name_table_sell_goods += "

    ";

    })

    $("#products_table_sell_goods tbody").html(product_name_table_sell_goods);

    }

    $(function() {

    // 复选框选中或者不选事件

    $(".sell_goods_info_list").on("change", "#table_products_sell_goods tbody input[type='checkbox']", function() {

    var save_table_sell_goodstest = $(this).parent().parent().children().eq(2).text();

    var save_table_sell_goods_hidden = $(this).parent().parent().children().eq(1).text();

    var save_table_sell_goods = {

    name: save_table_sell_goodstest,

    id: save_table_sell_goods_hidden

    };

    if($(this).prop("checked")) {

    product_name_sell_goods.push(save_table_sell_goods);

    } else {

    product_name_sell_goods.forEach(function(val, i) {

    if(val.name == save_table_sell_goods.name) {

    product_name_sell_goods.splice(i, 1)

    }

    })

    }

    show_table_sell_goods(product_name_sell_goods)

    })

    // 清空按钮涉及产品选取事件

    $("#products_btn_cencel_sell_goods").click(function() {

    $("#products_table_sell_goods tbody").html("");

    product_name_sell_goods = []

    $("#table_products_sell_goods tbody input:checked").prop("checked", "");

    })

    // 取消按钮涉及产品选取事件

    $(".choose_product_cencel_sell_goods").click(function() {

    // $(".product_choose_input_sell_goods").val(list_choose_sell_goods)

    $(".sell_goods_info_list").hide();

    $(".improve_serivice_request").show()

    flag_sell_goods = true

    })

    //   如果没有数据右边没有列表

    $(".products_btn_save_sell_goods").click(function() {


    flag_sell_goods = true

    if($("#products_table_sell_goods tbody tr").length == 0) {

    $(".sell_goods_info_list").hide();

    $(".improve_serivice_request").show()

    $("#workOrder_productRelaChoose_service_sell_goods").val("")

    $("#workOrder_service_sell_goods_hidden").val("")

    } else {

    var table_list_sell_goods = ""

    var table_list_sell_goods_num = ""

    $("#products_table_sell_goods tbody tr").each(function(i) {

    var text1 = $(this).children("td:first").text();

    var text2 = $(this).children("td:first").attr("id");

    table_list_sell_goods += text1 + ","

    table_list_sell_goods_num += text2 + ","

    });

    table_list_sell_goods = table_list_sell_goods.length > 0 ? table_list_sell_goods.substring(0, table_list_sell_goods.length - 1) : "";

    table_list_sell_goods_num = table_list_sell_goods_num.length > 0 ? table_list_sell_goods_num.substring(0, table_list_sell_goods_num.length - 1) : "";

    $("#workOrder_productRelaChoose_service_sell_goods").val(table_list_sell_goods)

    $("#workOrder_service_sell_goods_hidden").val(table_list_sell_goods_num)

    $(".sell_goods_info_list").hide();

    $(".improve_serivice_request").show()

    }

    product_name_sell_goods = []

    })

    // 点击叉叉删除对应一行数据

    $(".sell_goods_info_list").on("click", ".cencel_product_sell_goods", function() {

    var save_table_sell_goods = $(this).siblings().text()

    product_name_sell_goods.forEach(function(val, i) {

    if(val.name == save_table_sell_goods) {

    product_name_sell_goods.splice(i, 1)

    }

    })

    $(this).parent().remove()

    input_checked_sell_goods(product_name_sell_goods)

    })

    })

    你可能感兴趣的:(选中数据显示右边)

    编号 名称 全称
    " + val.name + "X