截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

likeArea.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. layui.define(["jquery", "form"], function (exports) {
  2. var $ = layui.$;
  3. var form = layui.form;
  4. var ojb = {
  5. init: function (province_lay_filte,city_lay_filte,district_lay_filte,province_name,city_name,district_name,province_id,city_id,district_id) {
  6. function areaSelect(data, element) {
  7. var html = '';
  8. for (var i in data) {
  9. html += "<option value=" + data[i]['id'] + ">" + data[i]['name'] + "</option>";
  10. }
  11. $(element).html(html);
  12. form.render('select');
  13. return data[0]['id'] === undefined ? 0 : data[0]['id'];
  14. }
  15. var first_id = areaSelect(getAllProvince(), $("[name='"+province_name+"']"));
  16. if(province_id !== undefined){
  17. $("[name='"+province_name+"']").val(province_id);
  18. form.render('select');
  19. first_id= province_id;
  20. }
  21. first_id = areaSelect(getAreaChildren(first_id), $("[name='"+city_name+"']"));
  22. if(city_id !== undefined){
  23. $("[name='"+city_name+"']").val(city_id);
  24. form.render('select');
  25. first_id= city_id;
  26. }
  27. areaSelect(getAreaChildren(first_id), $("[name='"+district_name+"']"));
  28. if(district_id !== undefined){
  29. $("[name='"+district_name+"']").val(district_id);
  30. form.render('select');
  31. }
  32. form.on('select('+province_lay_filte+')', function (data) {
  33. var first_id = areaSelect(getAreaChildren(data['value']), $("[name='"+city_name+"']"));
  34. areaSelect(getAreaChildren(first_id), $("[name='"+district_name+"']"));
  35. });
  36. form.on('select('+city_lay_filte+')', function (data) {
  37. areaSelect(getAreaChildren(data['value']), $("[name='"+district_name+"']"));
  38. });
  39. }
  40. };
  41. exports("likeArea", ojb);
  42. });