Няма описание

addmaintainProjectBF.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. $(function() {
  2. getbz()
  3. var ajaxUrl;
  4. var ids = helper.request.queryString("edit_id");
  5. if (ids) {
  6. ajaxUrl = "equipmentapi/api/WoRepairBase/upwxwptimestabs";
  7. getValue(ids);
  8. } else {
  9. ajaxUrl = "equipmentapi/api/WoRepairBase/addwxwptimes";
  10. }
  11. //保存
  12. $("#HY_save").click(function() {
  13. // if(!$("#bzid").val()) {
  14. // layer.confirm('请选择班组!', {
  15. // icon: 2,
  16. // btn: ['确定'] //按钮
  17. // });
  18. // return;
  19. // }
  20. addValue(ajaxUrl, ids);
  21. })
  22. })
  23. //添加
  24. function addValue(ajaxUrl, ids) {
  25. var $storages = window.localStorage;
  26. $.ajax({
  27. type: "get",
  28. url: huayi.config.callcenter_url + ajaxUrl,
  29. async: true,
  30. dataType: 'json',
  31. data: {
  32. id: ids,
  33. wxcenter: $("#wxcenter").val(), //维修项目
  34. timecount: $('#timecount').val(), // 是时长)
  35. bzid: $("#bzid option:selected").val() //班组
  36. },
  37. success: function(data) {
  38. if (data.state.toLowerCase() == 'success') {
  39. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  40. parent.layer.close(index); //再执行关闭
  41. layer.msg(data.message);
  42. parent.initTable();
  43. }
  44. }
  45. });
  46. }
  47. //获取详情
  48. function getValue(ids) {
  49. $.ajax({
  50. type: "get",
  51. url: huayi.config.callcenter_url + "equipmentapi/api/WoRepairBase/getwxwptimesbyid",
  52. async: true,
  53. dataType: 'json',
  54. data: {
  55. id: ids
  56. },
  57. success: function(data) {
  58. if (data.state.toLowerCase() == 'success') {
  59. console.log(data.data[0].bzid)
  60. // $('#bzid').selectpicker('val', data.data[0].bzid).trigger('change');
  61. // $("#bzid option:selected").val(data.data[0].bzid)//班组
  62. $("#bzid").val(data.data[0].bzid); //排查部门
  63. $('#bzid').selectpicker('refresh');
  64. $('#bzid').selectpicker('render');
  65. $('#wxcenter').val(data.data[0].wxcenter); //维修项目
  66. $('#timecount').val(data.data[0].timecount); // 时长
  67. }
  68. }
  69. });
  70. }
  71. // 获取班组
  72. function getbz() {
  73. $("#bzid").html('');
  74. $("#bzid").append('<option selected="selected" value="">请选择班组</option>');
  75. $.getJSON(huayi.config.callcenter_url + "equipmentapi/api/WoRepairBase/getallbzcount", function(data) {
  76. if (data.state.toLowerCase() == "success") {
  77. var province = data.data;
  78. for (var i = 0; i < province.length; i++) {
  79. $("<option value='" + province[i].id + "'>" + province[i].role_name + "</option>").appendTo("#bzid");
  80. $('#bzid').selectpicker('refresh');
  81. }
  82. }else{
  83. $("#bzid").empty();
  84. $("#bzid").selectpicker('refresh');
  85. }
  86. })
  87. }