Brak opisu

common.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. function getDicObjFn(obj) {
  2. return {
  3. ele:obj.ele,
  4. apiUrl: "Dictionary/GetDicValueListById",
  5. params: {
  6. id: obj.id
  7. },
  8. data: {
  9. textKey: 'F_Value',
  10. valueKey: 'F_ValueId'
  11. },
  12. getValue:obj.getValue?obj.getValue:'',
  13. getText:obj.getText?obj.getText:''
  14. }
  15. }
  16. //区域
  17. function selectCommonFn(obj) {
  18. var dataParam = {
  19. token: $.cookie("token")
  20. }
  21. if (obj.params) {
  22. var resultParam = Object.assign(dataParam, obj.params)
  23. }
  24. $(obj.ele).empty();
  25. $(obj.ele).append('<option selected="selected" value="">请选择</option>');
  26. $.ajax({
  27. type: "get",
  28. url: huayi.config.callcenter_url + obj.apiUrl,
  29. dataType: "json",
  30. async: true,
  31. data: resultParam,
  32. success: function(data) {
  33. if(data.state.toLowerCase() == "success") {
  34. var content = data.data;
  35. $(content).each(function(i, n) {
  36. $("<option value='" + n[obj.data.valueKey] + "'>" + n[obj.data.textKey] +
  37. "</option>").appendTo($(obj.ele));
  38. })
  39. if (obj.getValue) {
  40. $(obj.ele +" option:selected").val(obj.getValue);
  41. $(obj.ele +" option:selected").text(obj.getText);
  42. }
  43. }
  44. }
  45. });
  46. }