/**
* guoj
* 2020.05.26
* 承运商管理
*/
export default () => {
  let queryItem = "";
  let queryFileItem = "";
  var ddfrom = null;
  var ddfromH = null;
  var configA = null;
  var fromData = null;
  var grid = null;
  var gridA = null;
  var gridTemplate1B = null;
  var dataSelete = {};
  let dataType = 0;
  //获取下拉框
  getSelectGJ([{ "objectcode": "CARRIER_STATUS" }, { "objectcode": "CARRIER_TYPE" }, { "objectcode": "COMPANY_TYPE" },
  { "objectcode": "PAPER_TYPE", "groupcode1": "1" }], function (data) {
    dataSelete = data.data;
  });
  var opts = {
    //terrace显示全部，card分页显示
    skin: "card",
    //renderer:"grid",
    columns: [
      { id: "carrierId", name: "id", type: "ro", width: "100", hidden: true },
      { id: "carrierCode", name: "承运商编号", type: "ro", width: 150 },
      { id: "carrierName", name: "承运商名称", type: "ro", width: 150 },
      { id: "shortName", name: "简称", type: "ro", width: 150 },
      {
        id: "status",
        name: "承运商状态",
        type: "ro",
        width: 100,
        render: function (v) {
          return getSelectValue(dataSelete.CARRIER_STATUS, v);
        }
      },
      {
        id: "carrierType", name: "承运商类型", type: "ro", width: 100,
        render: function (v) {
          return getSelectValue(dataSelete.CARRIER_TYPE, v);
        }
      },
      { id: "regaddress", name: "注册地址", type: "ro", width: 100 },
      { id: "contactman", name: "联系人", type: "ro", width: 100 },
      { id: "tel", name: "联系方式", type: "ro", width: 100 },
      { id: "bankcode", name: "开户银行", type: "ro", width: 100 },
      { id: "invoicetitle", name: "发票抬头", type: "ro", width: 130 },
      { id: "legalman", name: "法人代表", type: "ro", width: 100 },
      { id: "bankaccoutno", name: "银行账号", type: "ro", width: 100 },
      { id: "memo", name: "备注", type: "ro", width: 130 },
      {
        id: "op",
        name: "操作",
        type: "button",
        align: "center",
        fixed: "right",
        width: 200,
        render: function () {
          return "删除^carrierManagement_deleteClick,修改^carrierManagement_updataClick,复制^carrierManagement_copy,详情^carrierManagement_details";
        }
      }
    ],
    multiselect: true,
    fixedLast: true, //开启固定列，固定最后一行，倒数第二列不能隐藏
    toolbar: [
      { type: "settings", labelWidth: 90, labelAlign: "right" },
      {
        type: "row",
        list: [
          { type: "input", className: "layui-col-md3", name: "carrierName", label: "承运商名称:" },
          { type: "input", className: "layui-col-md3", name: "carrierCode", label: "承运商编号:" },
          {
            type: "block", className: "layui-col-md3 form_btn_left",
            list: [
              { type: "button", className: "btn-normal", name: "querywork", value: "查询" },
              { type: "newcolumn" },
              { type: "button", name: "work_Reset", className: "normal", value: "重置" }
            ]
          },
          {
            type: "block", className: "layui-col-md3 right",
            list: [
              { type: "button", className: "btn-normal", name: "addBtn", offsetLeft: 10, value: "<i class='layui-icon layui-icon-add-1'></i>新增" }
            ]
          }
        ]
      }
    ],

    url: UPCLOUD_RDC_TMS_MAINDATA_SERVICE+"/tmsBaseCarrier/queryTmsBaseCarrier", //数据接口
    type: "post", //数据提交方式，默认为get
    pagebar: {
      buttons: [
        { text: "删除", className: "layui-btn-danger", name: "delete" }
      ]
    },
    contentType: "application/json",
    params: "{}", //查询提交参数，分页参数默认为pageNum,pageSize
    page: true, //是否启用分页
    totalCount: "totalCount" //总记录数字段，默认totalCount
  };
  //分页参数 pageSize pageNum
  grid = new PlgGrid(opts);
  grid.renderTo("carrierManagement_guojzhuans2");
  grid.attachEvent("onDataReady", function () {
    setTimeout(function () {
      layui.form.render();
    }, 200);
  });
  //分组拆分条件查询
  grid.loadData();

  //按钮添加方法
  grid.attachToolBarEvent("onButtonClick", function (name) {
    //查询
    if (name == "querywork") {
      var fdata = grid.getToolBarForm().getFormData();
      grid.setParams(JSON.stringify(fdata));
      grid.reload();
    }
    //新增
    if (name == "addBtn") {
      $("#carrierManagement_div4").html("");
      $("#carrierManagement_div4B").html("");
      ddfromH = new PlgForm(fromData);
      ddfromH.enableItem("carrierCode");
      cuttingScreen("#carrierManagement_div1");
      $("#carrierManagement_title").html("新增");
    }
    //重置
    if (name == "work_Reset") {
      grid.getToolBarForm().clear();
      grid.getToolBarForm().setFormData({ consignor: "" });
    }
  });
  //按钮添加方法
  grid.attachPageBarEvent(function (name) {
    //删除
    if (name == "delete") {
      let data = [];
      let datas = getDeleteAll(grid);
      datas.forEach(v => {
        data.push({ carrierId: v });
      });
      data = JSON.stringify(data);
      utilDelete(UPCLOUD_RDC_TMS_MAINDATA_SERVICE+"/tmsBaseCarrier/deleteTmsBaseCarrier", "post", data, function (data) {
        grid.reload();
      }, "application/json");
    }
  });
  //删除
  window.carrierManagement_deleteClick = function (rid) {
    grid.selectRowById(rid);
    let data = [];
    let datas = getDeleteAll(grid);
    datas.forEach(v => {
      data.push({ carrierId: v });
    });
    data = JSON.stringify(data);
    utilDelete(UPCLOUD_RDC_TMS_MAINDATA_SERVICE+"/tmsBaseCarrier/deleteTmsBaseCarrier", "post", data, function (data) {

      grid.reload();
    }, "application/json");
  };
  //修改
  window.carrierManagement_updataClick = function (rid, data) {
    $("#carrierManagement_div4").html("");
    ddfromH = new PlgForm(fromData);
    grid.selectRowById(rid);
    ddfromH.setFormData(data);
    ddfromH.disableItem("carrierCode");
    cuttingScreen("#carrierManagement_div1");
    $("#carrierManagement_title").html("编辑");
    //这个是绑定地址暂时不用
    $("#carrierManagement_div4B").html("");
    //gridA.renderTo("carrierManagement_div4B");
    //gridA.setParams(JSON.stringify({ "carrierId": data.carrierId }));
    //gridA.reload();
    //setMouth();
  };
  //复制
  window.carrierManagement_copy = function (rid, data) {
    $("#carrierManagement_div4").html("");
    ddfromH = new PlgForm(fromData);
    $("#carrierManagement_div4B").html("");
    grid.selectRowById(rid);
    data.carrierId = "";
    ddfromH.setFormData(data);
    cuttingScreen("#carrierManagement_div1");
    $("#carrierManagement_title").html("新增");
  };
  //详情
  window.carrierManagement_details = function (rid, rdata) {
    dataType = 0;
    grid.selectRowById(rid);
    cuttingScreen("#carrierManagement_div9");
    new PlgPanel({
      renderer: "carrierManagement_div422",
      skin: 2,
      header: {
        isShow: true,
        title: "基本信息"
      },
      defaultBody: {
        layoutCol: 3,
        valueBj: true,
        cols: [
          [{
            label: "承运商编码",
            value: rdata.carrierCode
          },
          {
            label: "承运商名称",
            value: rdata.carrierName
          },
          {
            label: "简称",
            value: rdata.shortName
          },
          {
            label: "承运商状态",
            value: getSelectValue(dataSelete.CARRIER_STATUS, rdata.status)
          }
          ],
          [
            {
              label: "承运商类型",
              value: getSelectValue(dataSelete.CARRIER_TYPE, rdata.carrierType)
            },
            {
              label: "注册地址",
              value: rdata.regaddress
            },
            {
              label: "联系人",
              value: rdata.contactman
            }, {
              label: "联系方式",
              value: rdata.tel
            }
          ],
          [
            {
              label: "开户银行",
              value: rdata.bankcode
            },
            {
              label: "发票抬头",
              value: rdata.invoicetitle
            },
            {
              label: "法人代表",
              value: rdata.legalman
            },
            {
              label: "银行账号",
              value: rdata.bankaccoutno
            },
            {
              label: "备注",
              value: rdata.memo
            }
          ]
        ]
      }
    });
  };
  //跳转页面
  var carousel = layui.carousel;
  carousel.render({
    elem: "#carrierManagement_div2",
    autoplay: false,
    index: 0,
    arrow: "none",
    indicator: "none",
    anim: "fade",
    width: "100%", //设置容器宽度
    height: "100%"
  });
  fromData = {
    renderer: "carrierManagement_div4",
    items: [
      { type: "settings", labelWidth: 90, labelAlign: "right" },
      {
        type: "row",
        list: [
          { type: "hidden", name: "carrierId", label: "id:", className: "layui-col-md3" },
          { type: "input", name: "carrierCode", label: "承运商编码:", className: "layui-col-md3", editable: false, validate: "NotEmpty", required: true },
          { type: "input", name: "carrierName", label: "承运商名称:", className: "layui-col-md3", editable: false, validate: "NotEmpty", required: true },
          { type: "input", name: "shortName", label: "简称:", className: "layui-col-md3" }
        ]
      },
      {
        type: "row",
        list: [
          { type: "combo", name: "carrierType", label: "承运商类型:", className: "layui-col-md3", options: dataSelete.CARRIER_TYPE },
          { type: "input", name: "regaddress", label: "注册地址:", className: "layui-col-md3" },
          { type: "combo", name: "status", label: "承运商状态:", className: "layui-col-md3", options: dataSelete.CARRIER_STATUS }
        ]
      },
      {
        type: "row",
        list: [
          { type: "input", name: "tel", label: "联系方式:", className: "layui-col-md3" },
          { type: "input", name: "bankcode", label: "开户银行:", className: "layui-col-md3" },
          { type: "input", name: "contactman", label: "联系人:", className: "layui-col-md3" }
        ]
      },
      {
        type: "row",
        list: [
          { type: "input", name: "legalman", label: "法人代表:", className: "layui-col-md3" },
          { type: "input", name: "bankaccoutno", label: "银行账号:", className: "layui-col-md3" },
          { type: "input", name: "invoicetitle", label: "发票抬头:", className: "layui-col-md3" }
        ]
      },
      {
        type: "row",
        list: [
          { type: "input", name: "memo", label: "备注:", className: "layui-col-md3" }
        ]
      }
    ]
  };
  configA = {
    renderer: "carrierManagement_Template1B", //挂载点
    indexActive: 0, //初始化默认选中项
    content: [{
      title: "图片",
      template: "<div id =\"carrierManagement_Template1B_divA\" style=\"height:100%;padding: 0px;\">" +
        "  <blockquote class=\"layui-elem-quote layui-quote-nm\" style=\"margin-top: 10px;\">  预览图：  </blockquote>" +
        "<div class=\"layui-upload-list\" id=\"carrierManagement_Template1B_divA2\"></div></div>"
    }, {
      title: "文件",
      template: "<div id =\"carrierManagement_Template1B_divB\" style=\"height:100%;padding: 0px;\">" +
        "<div class=\"layui-upload\">  <button type=\"button\" class=\"layui-btn\" style='float:left' id=\"carrierManagement_Template1B_divB1\">文件上传</button> </div>" +
        "<div id='carrierManagement_Template1B_divB2'></div></div>"
    }]
  };

  //返回
  $(document).on("click", "#carrierManagement_return", function () {
    if (dataType == 0) {
      cuttingScreen("#carrierManagement_div3");
    }
    else {
      dataType = 0;
      cuttingScreen("#carrierManagement_div1");
    }
  });
  //返回
  $(document).on("click", "#carrierManagement_returnA", function () {
    cuttingScreen("#carrierManagement_div1");
  });
  function cuttingScreen(name) {
    var dataList = ["#carrierManagement_div1", "#carrierManagement_div3",
      "#carrierManagement_div9", "#carrierManagement_Template"];
    for (var i = 0; i < dataList.length; i++) {
      if (dataList[i] == name) {
        $(dataList[i]).css("display", "block");
      }
      else {
        $(dataList[i]).css("display", "none");
      }
    }
  }
  //保存
  document.querySelector("#carrierManagement_save").onclick = function () {
    //数据data
    var data = ddfromH.getFormData();
    data.branchid = userGJ.p_carrierId;
    var feik = ddfromH.validate();
    if (!feik) {
      return;
    }
    //请求地址和类型
    var url = UPCLOUD_RDC_TMS_MAINDATA_SERVICE+"/tmsBaseCarrier/updateTmsBaseCarrier";
    var type = "post";
    var contentType = "application/json";
    //message新增为0，修改为1
    if (data.carrierId == null || data.carrierId == "") {
      url = UPCLOUD_RDC_TMS_MAINDATA_SERVICE+"/tmsBaseCarrier/addTmsBaseCarrier";
    }
    //调用ajax方法
    utilAjaxGJ(url, type, JSON.stringify(data), function (data) {

      cuttingScreen("#carrierManagement_div3");
      grid.reload();
    }, contentType);
  };
  //证件保存
  document.querySelector("#carrierManagement_Template_save").onclick = function () {
    //数据data
    var data = ddfrom.getFormData();
    if (data.todate - data.fromdate < 0) {
      PlgDialog.msg("有效期止必须大于有效期起");
      return;
    }
    var reg = /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}$)/; // 身份证号
    if (data.papertype === "01" && !reg.test(data.paperno)) {
      PlgDialog.msg("请输入正确的身份证号");
      return;
    }
    var feik = ddfrom.validate();
    if (!feik) {
      return;
    }
    var url = UPCLOUD_RDC_TMS_MAINDATA_SERVICE+"/pubPaper/updatePubPaper";
    data.fromdate = FormatDateTime(data.fromdate);
    data.todate = FormatDateTime(data.todate);
    data.papertypename = ddfrom.getCombo("papertype").getComboText();
    //message新增为0，修改为1
    if (data.paperid == null || data.paperid == "") {
      url = UPCLOUD_RDC_TMS_MAINDATA_SERVICE+"/pubPaper/addPubPaper";
    }
    //调用ajax方法
    utilAjaxGJ(url, "post", JSON.stringify(data), function (data) {

      cuttingScreen("#carrierManagement_div1");
      gridA.reload();
    }, "application/json");
  };
  var optsA = {
    //terrace显示全部，card分页显示
    skin: "card",
    //renderer:"grid",
    columns: [
      { id: "paperid", name: "id", type: "ro", width: "100", hidden: true },
      { id: "papertypename", name: "证件类型", type: "ro", width: 100 },
      { id: "paperno", name: "证件编号", type: "ro", width: 150 },
      { id: "paperauthority", name: "发证机构", type: "ro", width: 130 },
      { id: "fromdate", name: "证件有效期始", type: "ro", width: 130 },
      { id: "todate", name: "证件有效期止", type: "ro", width: 130 },
      { id: "daysremaining", name: "剩余过期天数", type: "ro", width: 130 },
      { id: "remarks", name: "备注", type: "ro", width: 330 },
      {
        id: "op",
        name: "操作",
        type: "button",
        align: "center",
        fixed: "right",
        width: 150,
        render: function () {
          return "删除^carrierManagementA_deleteClick,修改^carrierManagementA_updataClick,复制^carrierManagementA_copy,详情^carrierManagementA_details";
        }
      }
    ],
    multiselect: true,
    fixedLast: true, //开启固定列，固定最后一行，倒数第二列不能隐藏
    toolbar: [
      { type: "button", name: "addBtn", offsetLeft: 10, className: "plg-toolbar-right", value: "<i class='layui-icon layui-icon-add-1'></i>新增" }
    ],

    url: UPCLOUD_RDC_TMS_MAINDATA_SERVICE+"/pubPaper/queryPubPaper", //数据接口
    type: "post", //数据提交方式，默认为get
    pagebar: {
      buttons: [
        { text: "删除", className: "layui-btn-danger", name: "delete" }
      ]
    },
    contentType: "application/json",
    params: "{}", //查询提交参数，分页参数默认为pageNum,pageSize
    page: false, //是否启用分页
    totalCount: "totalCount" //总记录数字段，默认totalCount
  };
  //分页参数 pageSize pageNum
  gridA = new PlgGrid(optsA);

  //按钮添加方法
  function setMouth() {
    gridA.attachToolBarEvent("onButtonClick", function (name) {
      //新增
      if (name == "addBtn") {
        dataType = 2;
        cuttingScreen("#carrierManagement_Template");
        $("#carrierManagement_Template_title").text("新增");
        initFrom(1);
      }
    });
    //按钮添加方法
    gridA.attachPageBarEvent(function (name) {
      //删除
      if (name == "delete") {
        let data = [];
        let datas = getDeleteAll(gridA);
        datas.forEach(v => {
          let rd = gridA.getRowData(v);
          data.push(rd);
        });
        data = JSON.stringify(data);
        utilDelete(UPCLOUD_RDC_TMS_MAINDATA_SERVICE+"/pubPaper/deletePubPaper", "post", data, function (data) {
            gridA.reload();
        }, "application/json");
      }
    });
  }
  //删除
  window.carrierManagementA_deleteClick = function (rid, rdata) {
    gridA.selectRowById(rid);
    utilDelete(UPCLOUD_RDC_TMS_MAINDATA_SERVICE+"/pubPaper/deletePubPaper", "post", JSON.stringify([rdata]), function (data) {

      gridA.reload();
    }, "application/json");
  };
  //修改
  window.carrierManagementA_updataClick = function (rid, rdata) {
    dataType = 2;
    $("#carrierManagement_Template_title").text("修改");
    gridA.selectRowById(rid);
    cuttingScreen("#carrierManagement_Template");
    initFrom(2);
    ddfrom.setFormData(rdata);
    queryItem = {
      bizId: rdata.paperid,
      bizType: "0",
      enterpriseid: userGJ.p_enterpriseid
    };
    queryFileItem = {
      bizId: rdata.paperid + "file",
      bizType: "0",
      enterpriseid: userGJ.p_enterpriseid
    };
    getImgList(queryItem);
    setUploadFile(queryFileItem);
    getFileList(queryFileItem);
  };
  //复制
  window.carrierManagementA_copy = function (rid, rdata) {
    dataType = 2;
    $("#carrierManagement_Template_title").text("新增");
    gridA.selectRowById(rid);
    cuttingScreen("#carrierManagement_Template");
    initFrom(1);
    rdata.paperid = "";
    ddfrom.setFormData(rdata);
  };
  //详情
  window.carrierManagementA_details = function (rid, rdata) {
    dataType = 1;
    gridA.selectRowById(rid);
    cuttingScreen("#carrierManagement_div9");
    new PlgPanel({
      renderer: "carrierManagement_div422",
      skin: 2,
      header: {
        isShow: true,
        title: "基本信息"
      },
      defaultBody: {
        layoutCol: 3,
        valueBj: true,
        cols: [
          [
            {
              label: "证件类型",
              value: rdata.papertypename
            },
            {
              label: "证件编号",
              value: rdata.paperno
            },
            {
              label: "发证机构",
              value: rdata.paperauthority
            },
            {
              label: "证件有效期始",
              value: rdata.fromdate
            }
          ],
          [{
            label: "证件有效期止",
            value: rdata.todate
          },
          {
            label: "剩余过期天数",
            value: rdata.daysremaining + ""
          },
          {
            label: "备注",
            value: rdata.remarks
          }
          ]
        ]
      }
    });
  };
  function initFrom(type) {
    $("#carrierManagement_Template1A").html("");
    $("#carrierManagement_Template1B").html("");
    let paperData = grid.getSelectedRowData();
    ddfrom = new PlgForm(fromDataA);
    ddfrom.setFormData({ paperprovidortype: "Y", paperprovidor: paperData.carrierId, paperprovidorname: paperData.carrierName });
    if (type == 1) {
      return;
    }
    new PlgTabs(configA).on(function (ele) {
      //设置table是哪页
      tables = ele.index;
    });
    gridTemplate1B.renderTo("carrierManagement_Template1B_divB2");
  }
  fromDataA = {
    renderer: "carrierManagement_Template1A",
    items: [
        { type: "settings", labelWidth: 90, labelAlign: "left" },
        {
            type: "row",
            list: [
                { type: "hidden", name: "paperid", label: "id:", className: "layui-col-md3" },
                { type: "combo", name: "papertype", label: "证件类型:", options: dataSelete.PAPER_TYPE, validate: "NotEmpty", required: true, className: "layui-col-md3" },
                { type: "input", name: "paperno", label: "证件编号:", editable: false, validate: "NotEmpty", required: true, className: "layui-col-md3" },
                { type: "input", name: "paperauthority", label: "发证机构:", className: "layui-col-md3" },
                { type: "hidden", name: "paperprovidor", label: "证件对象id:", disabled: true, className: "layui-col-md3" },
                { type: "combo", name: "paperprovidortype", label: "证件对象类型:", options: dataSelete.COMPANY_TYPE, disabled: true, className: "layui-col-md3" },
                { type: "calendar", name: "fromdate", label: "有效期起:", validate: "NotEmpty", required: true, className: "layui-col-md3" },
                { type: "calendar", name: "todate", label: "有效期止:", validate: "NotEmpty", required: true, className: "layui-col-md3" },
                { type: "input", name: "paperprovidorname", label: "证件对象名称:", disabled: true, className: "layui-col-md3" },
                { type: "input", name: "remarks", label: "备注:", className: "layui-col-md9" }
            ]
        }
    ]
  };
  var optsTemplate1B = {
    //terrace显示全部，card分页显示
    skin: "card",
    //renderer:"grid",
    columns: [
      { id: "id", name: "id", type: "ro", width: "100", hidden: true },
      { id: "originFileName", name: "文件名", type: "ro" },
      { id: "createDay", name: "上传时间", type: "ro" },
      { id: "fileSize", name: "大小", type: "ro" },
      {
        id: "op",
        name: "操作",
        type: "button",
        align: "center",
        fixed: "right",
        width: 50,
        render: function () {
          return "删除^carrierManagement_Template1B__delete";
        }
      }
    ],
    // multiselect: true,

    url: "/app/biz-file/list", //数据接口
    type: "post", //数据提交方式，默认为get
    contentType: "application/json",
    params: "{}", //查询提交参数，分页参数默认为pageNum,pageSize
    page: false, //是否启用分页
    totalCount: "totalCount" //总记录数字段，默认totalCount
  };
  //分页参数 pageSize pageNum
  gridTemplate1B = new PlgGrid(optsTemplate1B);

  //删除
  window.carrierManagement_Template1B__delete = function (id) {
    utilAjaxGJ("/app/biz-file/del", "post", { ids: id }, () => {
      layer.msg("成功");
      getFileList(queryFileItem);
    });
  };
  //图片上传---------------------------------------------------------------------------

  //查询图片
  var imgList = [];
  function getImgList(data) {
    imgList = [];
    $("#carrierManagement_Template1B_divA2").html("");
    utilAjaxGJ("/app/biz-file/list", "post", data, (data) => {
      let imgListData = data.data;
      for (var i = 0; i < imgListData.length; i++) {
        imgList.push({ fileUrl: imgListData[i].file.fileUrl })
        $("#carrierManagement_Template1B_divA2").append("<img onclick='showCustImg(this)'  class='leftImg' src='" + imgListData[i].file.fileUrl + "'/>" +
          "<div class='deleteCustomerImg' id='" + imgListData[i].id + "' onclick='deletecustImg(this)'>X</div>");
      }
      $("#carrierManagement_Template1B_divA2").append("<img id='carrierManagement_Template1B_divA1' class='leftImg' src='/img/addimg.png'/>");
      setUploadMouth(queryItem);
    });

  }
  //设置上传
  function setUploadMouth(data) {
    var token = window.localStorage.getItem("authorization");
    if (token == null || token == "") {
      PlgDialog.msg("登录状态异常，请重新登录！");
      window.location.href = "/menu?path=login";
      return;
    }
    var upload = layui.upload;
    upload.render({
      elem: "#carrierManagement_Template1B_divA1",
      url: "/app/biz-file/upload",
      accept: "images",
      field: "files",
      acceptMime: "image/*",
      headers: { "Authorization": token },
      data: data,
      contentType: "multipart/form-data",
      size: 10 * 1024,
      before: function () { //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
        PlgDialog.load(2, { shade: [0.6, "#fff"] });
      },
      done: function () {
        layer.closeAll();
        getImgList(queryItem);
      }
    });
  }
  //删除
  window.deletecustImg = function (data) {
    utilAjaxGJ("/app/biz-file/del", "post", { ids: data.id }, () => {
      layer.msg("成功");
      getImgList(queryItem);
    });
  };
  //展示图片
  window.showCustImg = function (data) {
    let index = 0;
    for(let i=0;i<imgList.length;i++){
      let t = imgList[i];
      if (t.fileUrl == data.src) index = i;
    }
    imageView(imgList,index);
  };
  //设置上传文件
  function setUploadFile(data) {
    var token = window.localStorage.getItem("authorization");
    if (token == null || token == "") {
      PlgDialog.msg("登录状态异常，请重新登录！");
      window.location.href = "/menu?path=login";
      return;
    }
    var upload = layui.upload;
    upload.render({
      elem: "#carrierManagement_Template1B_divB1",
      url: "/app/biz-file/upload",
      accept: "file",
      field: "files",
      headers: { "Authorization": token },
      data: data,
      contentType: "multipart/form-data",
      size: 10 * 1024,
      before: function () { //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
        PlgDialog.load(2, { shade: [0.6, "#fff"] });
      },
      done: function () {
        layer.closeAll();
        getFileList(queryFileItem);
      }
    });
  }
  //查询文件
  function getFileList(data) {
    utilAjaxGJ("/app/biz-file/list", "post", data, (data) => {
      let dList = data.data;
      for (var i = 0; i < dList.length; i++) {
        dList[i].originFileName = dList[i].file.originFileName;
        dList[i].createDay = dList[i].file.createDay;
        dList[i].fileSize = dList[i].file.fileSize / 1024 + "KB";
      }
      gridTemplate1B.getGrid().clearAll();
      //分组拆分条件查询
      gridTemplate1B.loadData({
        "success": true, "message": "查询成功", "code": "200", "data": {
          "list": dList, "totalCount": dList.length, "pageCount": 1, "pageNum": 1, "pageSize": dList.length, "startRow": 0, "endRow": dList.length
        }
      });
    });

  }
};