/**
   * guoj
   * 2020.06.22
   * 送货站台释放
      */
    import { UPCLOUD_RDC_TMS_MAINDATA_SERVICE,UPCLOUD_RDC_TMS_BUSINESS_SERVICE,UPCLOUD_RDC_TMS_INTERFACE_SERVICE} from '@/config/serviceSettings.js';
    import { getSelectGJ, querySysPicture } from '@/utils/prolog.ajax.js';
export default () => {
  var grid;
  var grid2;
  var gridB;

  //到场车辆信息
  var opts = {
    //terrace显示全部，card分页显示
    skin: "card",
    //renderer:"grid",
    columns: [
      { id: "appointBillNo", name: "id", type: "ro", width: "130", hidden: true },
      { id: "appointVehicle", name: "车辆", type: "ro", width: "100" },
      { id: "shipbillno", name: "运单号", type: "ro", width: "110" },
      { id: "codenumber", name: "打码号", type: "ro", width: "110" },
      { id: "customerCode", name: "承运商", type: "ro", width: "80" },
      { id: "appointDate", name: "到场时间", type: "ro", width: "80" },
      { id: "vipSign", name: "紧急标识", type: "ro", width: "90" },
      { id: "appointVehicleModel", name: "车型", type: "ro", width: "110" },
      { id: "appointPackage", name: "件数", type: "ro", width: "80" },
      { id: "temporaryPlace", name: "候车位", type: "ro", width: "80" }
    ],
    multiselect: false,

    url: UPCLOUD_RDC_TMS_BUSINESS_SERVICE+"/bookingManage/sendGoodsPlatformsQuery",//数据接口
    type: "post",//数据提交方式，默认为get
    contentType: "application/json",
    params: JSON.stringify({ "type": "01", pageNum: 1, pageSize: 500 }),//查询提交参数，分页参数默认为pageNum,pageSize
    page: false, //是否启用分页
    pagebar: null,
    totalCount: "totalCount" //总记录数字段，默认totalCount
  };
  grid = new PlgGrid(opts);
  grid.renderTo("platformRelease_zhuTableLeftB1");
  grid.loadData();
  //单击事件
  grid.on("onRowSelect", function() {
      var data = grid.getSelectedRowData();
      if(data.shipbillno == null){
        return;
      }
      gridB.setParams(JSON.stringify({"shipbillno": data.shipbillno, pageNum: 1, pageSize: 500 }));
      gridB.reload();
  });
  //到场车辆明细信息
  var optsB = {
    //terrace显示全部，card分页显示
    skin: "card",
    //renderer:"grid",
    columns: [
      { id: "lineid", name: "id", type: "ro", width: "130", hidden: true },
      { id: "branchname", name: "当前仓名称", type: "ro", width: "100" },
      { id: "consignorname", name: "货主名称", type: "ro", width: "110" },
      { id: "shipbillno", name: "运单号", type: "ro", width: "110" },
      { id: "refbillno", name: "业务单编号", type: "ro", width: "80" },
      { id: "seqno", name: "明细序号", type: "ro", width: "80" },
      { id: "itemno", name: "物料编码", type: "ro", width: "90" },
      { id: "itemname", name: "物料名称", type: "ro", width: "110" },
      { id: "itemtype", name: "物料类型", type: "ro", width: "80" },
      { id: "pcs", name: "件数", type: "ro", width: "80" },
      { id: "odd", name: "零散数", type: "ro", width: "80" },
      { id: "weight", name: "重量", type: "ro", width: "80" },
      { id: "vol", name: "体积", type: "ro", width: "80" },
      { id: "price", name: "单价", type: "ro", width: "80" },
      { id: "lotno", name: "批号", type: "ro", width: "80" },
      { id: "yielddate", name: "生产日期", type: "ro", width: "80" },
      { id: "expdate", name: "有效期至", type: "ro", width: "80" }
    ],
    multiselect: false,

    url: UPCLOUD_RDC_TMS_BUSINESS_SERVICE+"/bookingManage/tmsShipbillDQuery",//数据接口
    type: "post",//数据提交方式，默认为get
    contentType: "application/json",
    params: JSON.stringify({ "shipbillno": "Y0730005", pageNum: 1, pageSize: 500 }),//查询提交参数，分页参数默认为pageNum,pageSize
    page: false, //是否启用分页
    pagebar: null,
    totalCount: "totalCount" //总记录数字段，默认totalCount
  };
  gridB = new PlgGrid(optsB);
  gridB.renderTo("platformRelease_zhuTableLeftB2");

  //空置站台信息
  var opts2 = {
    //terrace显示全部，card分页显示
    skin: "card",
    //renderer:"grid",
    columns: [
      { id: "platformId", name: "id", type: "ro", width: "80", hidden: true },
      { id: "platformCode", name: "站台编码", type: "ro" },
      { id: "modelType", name: "最大车型", type: "ro" },
      { id: "vehicleNo", name: "装货车牌", type: "ro" },
      {
        id: "op", name: "操作", type: "button", align: "center", fixed: "right", width: "100", render: function (v, rd) {
          let text = rd.vehicleStatus == "02" ? "释放^carrier_updataClick2" : "已释放^carrier_updataClick3";
          return text;
        }
      }
    ],
    multiselect: false,

    url: UPCLOUD_RDC_TMS_MAINDATA_SERVICE+"/platform/queryBasePlatform",//数据接口
    type: "post",//数据提交方式，默认为get
    contentType: "application/json",
    params: JSON.stringify({ platformTypes: ["01","03"], pageNum: 1, pageSize: 500 }),//查询提交参数，分页参数默认为pageNum,pageSize
    page: false, //是否启用分页
    pagebar: null,
    totalCount: "totalCount" //总记录数字段，默认totalCount
  };
  grid2 = new PlgGrid(opts2);
  grid2.renderTo("platformRelease_zhuFromRightB");
  grid2.loadData();

  // 按钮事件
  $(".platformRelease_zhu_btn").click(function () {
    let name = $(this).attr("name");
    // 叫号
    if (name == "platformRelease_zhu_btn_save") {
      let idh = grid.getSelectedRowId();
      if (idh == "" || idh == null) {
        layer.msg("请选择一行车辆");
        return;
      }
      let datah = grid.getRowData(idh);
      let idd = grid2.getSelectedRowId();
      if (idd == "" || idd == null) {
        layer.msg("请选择一行站台");
        return;
      }
      let datad = grid2.getRowData(idd);
      if (datad.vehicleStatus == "02") {
        layer.msg("该站台被占用");
        return;
      }
      let dataitem = { tmsAppointBillVO: datah, basePlatformVO: datad };
      utilAjaxGJ(UPCLOUD_RDC_TMS_BUSINESS_SERVICE+"/bookingManage/platformsGetnumber", "post", JSON.stringify(dataitem), () => {
        layer.msg("成功");
        grid.reload();
        grid2.reload();
      }, "application/json");
    }
    //刷新
    else if (name == "platformRelease_zhu_btn_refresh") {
      grid.reload();
      grid2.reload();
    }
  });

  //释放
  window.carrier_updataClick2 = function (v, rdata) {
    rdata.vehicleStatus = "01";
    utilAjaxGJ(UPCLOUD_RDC_TMS_BUSINESS_SERVICE+"/bookingManage/platformsRelease", "post", JSON.stringify({ basePlatformVO: rdata }), () => {
      layer.msg("成功");
      grid.reload();
      grid2.reload();
    }, "application/json");
  };
  //释放
  window.carrier_updataClick3 = function () {
  };
};