
<!-- 参数
1、字段值  file
2、数据值  data
3、修改时候的值 fvalue
 -->


<div id="<?=$field?>" class="xm-select-demo"></div>
<input type="hidden"  name="<?=$field?>" class="<?=$field?>" value="<?=$fvalue?>">

<script src="<?=TPLURL?>/js/lay-module/xm-select/xm-select.js"></script>

<script>
   // var xmdata= <?= $xmselect_str?>;
   layui.use(['form'], function () {
  console.log(<?=$data?>)
   	   $ = layui.jquery;
       form = layui.form;
      xmSelect.render({
        el: '#<?=$field?>',
        initValue: [<?=$fvalue?>],
        direction:"down",
        data: <?=$data?>,
        on: function(data){
		        changefield(data)
	      },
      
    });


 function changefield(data){

  
    var arr = data.arr;
    //change, 此次选择变化的数据,数组
    var change = data.change;
     var ids=[];
    for (var i = arr.length-1; i >= 0; i--) {
        ids.push(arr[i].value);
    }
    $(".<?=$field?>").val(ids.join(","));
 }


  })
</script>
 <style>
 	.xm-select-demo{width:100%;}
 </style>