| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- $(function() {
- getbz()
- var ajaxUrl;
- var ids = helper.request.queryString("edit_id");
- if (ids) {
- ajaxUrl = "equipmentapi/api/WoRepairBase/upwxwptimestabs";
- getValue(ids);
- } else {
- ajaxUrl = "equipmentapi/api/WoRepairBase/addwxwptimes";
- }
- //保存
- $("#HY_save").click(function() {
- // if(!$("#bzid").val()) {
- // layer.confirm('请选择班组!', {
- // icon: 2,
- // btn: ['确定'] //按钮
- // });
- // return;
- // }
- addValue(ajaxUrl, ids);
- })
-
- })
- //添加
- function addValue(ajaxUrl, ids) {
- var $storages = window.localStorage;
- $.ajax({
- type: "get",
- url: huayi.config.callcenter_url + ajaxUrl,
- async: true,
- dataType: 'json',
- data: {
- id: ids,
- wxcenter: $("#wxcenter").val(), //维修项目
- timecount: $('#timecount').val(), // 是时长)
- bzid: $("#bzid option:selected").val() //班组
- },
- success: function(data) {
- if (data.state.toLowerCase() == 'success') {
- var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
- parent.layer.close(index); //再执行关闭
- layer.msg(data.message);
- parent.initTable();
- }
- }
- });
- }
- //获取详情
- function getValue(ids) {
- $.ajax({
- type: "get",
- url: huayi.config.callcenter_url + "equipmentapi/api/WoRepairBase/getwxwptimesbyid",
- async: true,
- dataType: 'json',
- data: {
- id: ids
- },
- success: function(data) {
- if (data.state.toLowerCase() == 'success') {
- console.log(data.data[0].bzid)
-
- // $('#bzid').selectpicker('val', data.data[0].bzid).trigger('change');
- // $("#bzid option:selected").val(data.data[0].bzid)//班组
- $("#bzid").val(data.data[0].bzid); //排查部门
- $('#bzid').selectpicker('refresh');
- $('#bzid').selectpicker('render');
- $('#wxcenter').val(data.data[0].wxcenter); //维修项目
- $('#timecount').val(data.data[0].timecount); // 时长
- }
- }
- });
- }
- // 获取班组
- function getbz() {
- $("#bzid").html('');
- $("#bzid").append('<option selected="selected" value="">请选择班组</option>');
- $.getJSON(huayi.config.callcenter_url + "equipmentapi/api/WoRepairBase/getallbzcount", function(data) {
- if (data.state.toLowerCase() == "success") {
- var province = data.data;
- for (var i = 0; i < province.length; i++) {
- $("<option value='" + province[i].id + "'>" + province[i].role_name + "</option>").appendTo("#bzid");
- $('#bzid').selectpicker('refresh');
- }
- }else{
- $("#bzid").empty();
- $("#bzid").selectpicker('refresh');
- }
- })
- }
|