/**
* guoj
* 2020.09.21
* 费用合同管理
*/
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 startTime = Prolog.formatDate(new Date(), "%YY-%MM") + "-01 00:00:00";
  var endTime = Prolog.formatDate(new Date()) + " 23:59:59";

  //获取下拉框
  let dataSelect;
  getSelectGJ([
    { "objectcode": "COMPANY_TYPE", "groupcode2": "1" }
  ], function (data) {
    dataSelect = data.data;
    dataSelect.COMPANY_TYPE.unshift({ "text": "", "value": "" });
  });

  var gridB;
  let gridC;
  //应收方table
  var userTable = {
    columns: [
      { id: "companyid", name: "id", type: "ro", width: "130", hidden: true },
      { id: "companycode", name: "编号", type: "ro" },
      { id: "companyname", name: "名称", type: "ro" },
      { id: "companytypeName", name: "单位类型", type: "ro" }
    ],
    toolbar: [
      { type: "settings", labelWidth: 60, labelAlign: "right" },
      {
        type: "row",
        list: [
          { type: "input", name: "companycode", label: "单位编码:", className: "layui-col-md6" },
          { type: "input", name: "companyname", label: "单位名称:", className: "layui-col-md6" },
          { type: "combo", name: "companytype", label: "单位类型:", className: "layui-col-md6", options: dataSelect.COMPANY_TYPE, readonly: true },
          {
            type: "block", className: "layui-col-md6 form_btn_left",
            list: [
              { type: "button", name: "querycarr", className: "btn-normal", value: "查询" },
              { type: "newcolumn" },
              { type: "button", name: "car_Reset", value: "重置" }
            ]
          }
        ]
      }
    ],
    multiselect: false,
    pagebar: { type: "simple" },

    url: UPCLOUD_RDC_TMS_MAINDATA_SERVICE+"/pubCompany/queryCompany", //数据接口
    type: "post", //数据提交方式，默认为get
    contentType: "application/json",
    params: JSON.stringify({}), //查询提交参数，分页参数默认为pageNum,pageSize
    page: true, //是否启用分页
    totalCount: "totalCount" //总记录数字段，默认totalCount
  };
  //费用规则table
  var ruleTable = {
    columns: [
      { id: "feeRuleId", name: "id", type: "ro", width: "130", hidden: true },
      { id: "feeRuleId", name: "费用规则编号", type: "ro" },
      { id: "feeRuleName", name: "费用规则名称", type: "ro" }
    ],
    multiselect: false,

    url: UPCLOUD_RDC_TMS_BUSINESS_SERVICE+"/bmsFeeRule/queryBmsFeeRule", //数据接口
    type: "post", //数据提交方式，默认为get
    pagebar: { type: "simple" },
    params: "{}", //查询提交参数，分页参数默认为pageNum,pageSize
    contentType: "application/json",
    page: true, //是否启用分页
    totalCount: "totalCount" //总记录数字段，默认totalCount
  };
  //费用项目table
  var objectTable = {
    columns: [
      { id: "feetypeid", name: "id", type: "ro", width: "130", hidden: true },
      { id: "feetypecode", name: "费用项目编号", type: "ro" },
      { id: "feetypename", name: "费用项目名称", type: "ro" }
    ],
    multiselect: false,

    url: UPCLOUD_RDC_TMS_BUSINESS_SERVICE+"/bmsFeeType/queryBmsFeeType",//数据接口
    type: "post", //数据提交方式，默认为get
    pagebar: { type: "simple" },
    params: "{}", //查询提交参数，分页参数默认为pageNum,pageSize
    contentType: "application/json",
    page: true, //是否启用分页
    totalCount: "totalCount" //总记录数字段，默认totalCount
  };
  var opts = {
    //terrace显示全部，card分页显示
    skin: "card",
    //renderer:"grid",
    columns: [
      { id: "contractId", name: "id", type: "ro", width: "100", hidden: true },
      { id: "contractNo", name: "合同编号", type: "ro", width: 100 },
      { id: "contractName", name: "合同名称", type: "ro", width: 130 },
      { id: "receivableCode", name: "应收方编号", type: "ro", width: 100 },
      { id: "receivableName", name: "应收方名称", type: "ro", width: 100 },
      { id: "payableCode", name: "应付方编号", type: "ro", width: 100 },
      { id: "payableName", name: "应付方名称", type: "ro", width: 100 },
      { id: "contractdateFrom", name: "合同开始时间", type: "ro", width: 130 },
      { id: "contractdateTo", name: "合同结束时间", type: "ro", width: 130 },
      { id: "contractdatePostpone", name: "合同顺延时间", type: "ro", width: 130 },
      { id: "receivablePerson", name: "应收方联系人", type: "ro", width: 110 },
      { id: "payablePerson", name: "应付方联系人", type: "ro", width: 110 },
      { id: "memo", name: "备注", type: "ro", width: 110 },
      {
        id: "op", name: "操作", type: "button", align: "center", fixed: "right", width: 200, render: function () {
          return "删除^costContract_deleteClick,修改^costContract_updataClick,复制^costContract_copy,详情^costContract_details";
        }
      }
    ],
    multiselect: true,
    fixedLast: true, //开启固定列，固定最后一行，倒数第二列不能隐藏
    toolbar: [
      { type: "settings", labelWidth: 90, labelAlign: "right" },
      {
        type: "row",
        list: [
          { type: "calendar", name: "sdate", label: "开始时间:", className: "layui-col-md3", value: startTime },
          { type: "calendar", name: "edate", label: "结束时间:", className: "layui-col-md3", value: endTime },
          {
            className: "layui-col-md3",
            type: "selectTable",
            placeholder: "请选择应收方",
            readonly: false,
            table: userTable,
            tableWidth: 500,
            tableHeight: 400,
            fieldText: "companyname",
            fieldValue: "companyid",
            name: "receivableId",
            label: "应收方:",
            listener: function (Grid) {
              setMethod(Grid, userTable, function () {
              });
            }
          },
          {
            className: "layui-col-md3",
            type: "selectTable",
            placeholder: "请选择应付方",
            readonly: false,
            table: userTable,
            tableWidth: 500,
            tableHeight: 400,
            fieldText: "companyname",
            fieldValue: "companyid",
            name: "payableId",
            label: "应付方:",
            listener: function (Grid) {
              setMethod(Grid, userTable, function () {
              });
            }
          },
          { type: "input", name: "contractNo", label: "合同编号:", className: "layui-col-md3" },
          {
            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-md6 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_BUSINESS_SERVICE+"/bmsFeeContract/queryBmsFeeContract",//数据接口
    type: "post",//数据提交方式，默认为get
    pagebar: {
      buttons: [
        { text: "删除", className: "layui-btn-danger", name: "delete" }
      ]
    },
    contentType: "application/json",
    params: JSON.stringify({ sdate: startTime, edate: endTime }),//查询提交参数，分页参数默认为pageNum,pageSize
    page: true, //是否启用分页
    totalCount: "totalCount" //总记录数字段，默认totalCount
  };
  //分页参数 pageSize pageNum
  var grid = new PlgGrid(opts);
  grid.renderTo("costContract_guojzhuans2A");
  grid.loadData();
  //按钮添加方法
  grid.attachToolBarEvent("onButtonClick", function (name) {
    if (name == "querywork") {
      var fdata = grid.getToolBarForm().getFormData();
      fdata.sdate = FormatDateTime(fdata.sdate);
      fdata.edate = Prolog.formatDate(fdata.edate) + " 23:59:59";
      if (fdata.sdate > fdata.edate) {
        layer.msg("开始时间不能大于结束时间");
        return false;
      }
      fdata.payableId = fdata.payableId == "" || fdata.payableId == null ? "" : JSON.parse(fdata.payableId)[0];
      fdata.receivableId = fdata.receivableId == "" || fdata.receivableId == null ? "" : JSON.parse(fdata.receivableId)[0];
      grid.setParams(JSON.stringify(fdata));
      grid.reload();
      gridB.getGrid().clearAll();
    }
    if (name == "addBtn") {
      $("#costContract_div4").html("");
      setFromView();
      setViewName("#costContract_div1");
      $("#costContract_title").html("新增");
    }
    if (name == "work_Reset") {
      grid.getToolBarForm().clear();
      grid.getToolBarForm().getDForm().setText("receivableId", "");
      grid.getToolBarForm().getDForm().setText("payableId", "");
      grid.getToolBarForm().setFormData({ sdate: startTime, edate: endTime });
    }
  });
  //按钮添加方法
  grid.attachPageBarEvent(function (name) {
    //删除
    if (name == "delete") {
      let data = [];
      let datas = getDeleteAll(grid);
      datas.forEach(v => {
        data.push(grid.getRowData(v));
      });
      data = JSON.stringify(data);
      utilDelete(UPCLOUD_RDC_TMS_BUSINESS_SERVICE+"/bmsFeeContract/bmsFeeContractDelete", "post", data, function (data) {
        grid.reload();
      }, "application/json");
    }
  });
  //单击事件
  grid.on("onRowSelect", function (id) {
    let dataItem = grid.getRowData(id);
    let data = JSON.stringify({ "contractId": id, "pageNum": "1", "pageSize": "10" });
    setMinList(gridB, data, dataItem);
  });
  function setMinList(copyGrid, data, dataItem) {
    copyGrid.getGrid().clearAll();
    utilAjaxGJ(UPCLOUD_RDC_TMS_BUSINESS_SERVICE+"/bmsFeeContract/queryBmsFeeContractItem", "post", data, (data) => {
      let dList = data.data;
      for (var i = 0; i < dList.length; i++) {
        dList[i].receivableCode = dataItem.receivableCode;
        dList[i].receivableName = dataItem.receivableName;
      }
      //分组拆分条件查询
      copyGrid.loadData({
        "success": true, "message": "查询成功", "code": "200", "data": {
          "list": dList, "totalCount": dList.length, "pageCount": 1, "pageNum": 1, "pageSize": dList.length, "startRow": 0, "endRow": dList.length
        }
      });
    }, "application/json");
  }
  //删除
  window.costContract_deleteClick = function (rid, rdata) {
    grid.selectRowById(rid);
    rdata = JSON.stringify([rdata]);
    utilDelete(UPCLOUD_RDC_TMS_BUSINESS_SERVICE+"/bmsFeeContract/bmsFeeContractDelete", "post", rdata, function (data) {

      grid.reload();
    }, "application/json");
  };
  //修改
  window.costContract_updataClick = function (rid, data) {
    $("#costContract_div4").html("");
    setFromView();
    grid.selectRowById(rid);
    gridC.getToolBarForm().setFormData(data);
    gridC.getToolBarForm().disableItem("contractNo");
    gridC.getToolBarForm().disableItem("contractName");
    let rdata = JSON.stringify({ "contractId": data.contractId, "pageNum": "1", "pageSize": "10" });
    setMinList(gridC, rdata, data);
    gridC.getToolBarForm().getDForm().setText("receivableIdFrom", data.receivableName);
    gridC.getToolBarForm().getDForm().setText("payableIdFrom", data.payableName);
    setViewName("#costContract_div1");
    $("#costContract_title").html("编辑");
  };
  //复制
  window.costContract_copy = function (rid, data) {
    $("#costContract_div4").html("");
    setFromView();
    // let rdata = JSON.stringify({ "contractId": data.contractId, "pageNum": "1", "pageSize": "10" });
    // setMinList(gridC,rdata,data);
    grid.selectRowById(rid);
    data.contractId = "";
    gridC.getToolBarForm().setFormData(data);
    gridC.getToolBarForm().getDForm().setText("receivableIdFrom", data.receivableName);
    gridC.getToolBarForm().getDForm().setText("payableIdFrom", data.payableName);
    setViewName("#costContract_div1");
    $("#costContract_title").html("新增");
  };
  //详情
  window.costContract_details = function (rid, rdata) {
    grid.selectRowById(rid);
    setViewName("#costContract_div9");
    new PlgPanel({
      renderer: "costContract_div422",
      skin: 2,
      header: {
        isShow: true,
        title: "基本信息"
      },
      defaultBody: {
        layoutCol: 3,
        valueBj: true,
        cols: [
          [
            { label: "合同编号", value: rdata.contractNo },
            { label: "合同名称", value: rdata.contractName },
            { label: "应收方编号", value: rdata.receivableCode },
            { label: "应收方名称", value: rdata.receivableName }
          ],
          [
            { label: "应付方编号", value: rdata.payableCode },
            { label: "应付方名称", value: rdata.payableName },
            { label: "合同开始时间", value: rdata.contractdateFrom },
            { label: "合同结束时间", value: rdata.contractdateTo }
          ],
          [
            { label: "合同顺延时间", value: rdata.contractdatePostpone },
            { label: "应收方联系人", value: rdata.receivablePerson },
            { label: "应付方联系人", value: rdata.payablePerson },
            { label: "备注", value: rdata.memo }
          ]
        ]
      }
    });
  };

  var optsB = {
    //terrace显示全部，card分页显示
    skin: "card",
    //renderer:"grid",
    columns: [
      { id: "contractLineid", name: "id", type: "ro", width: "100", hidden: true },
      { id: "contractNo", name: "合同编号", type: "ro" },
      { id: "contractName", name: "合同名称", type: "ro" },
      {
        id: "receivableCode", name: "应收方编号", type: "ro"
      },
      { id: "receivableName", name: "应收方名称", type: "ro" },
      { id: "feetypecode", name: "费用项目编号", type: "ro" },
      { id: "feetypename", name: "费用项目名称", type: "ro" },
      { id: "feeruleName", name: "规则名称", type: "ro" },
      { id: "memo", name: "备注", type: "ro" }
    ],

    url: UPCLOUD_RDC_TMS_BUSINESS_SERVICE+"/bmsFeeContract/queryBmsFeeContractItem",//数据接口
    type: "post",//数据提交方式，默认为get
    contentType: "application/json",
    params: "{}",//查询提交参数，分页参数默认为pageNum,pageSize
    page: false, //是否启用分页
    totalCount: "totalCount" //总记录数字段，默认totalCount
  };
  //分页参数 pageSize pageNum
  gridB = new PlgGrid(optsB);
  gridB.renderTo("costContract_guojzhuans2B");
  //跳转页面
  var carousel = layui.carousel;
  carousel.render({
    elem: "#costContract_div2",
    autoplay: false,
    index: 0,
    arrow: "none",
    indicator: "none",
    anim: "fade",
    width: "100%", //设置容器宽度
    height: "100%"
  });
  let dataView = ["#costContract_div1", "#costContract_div3", "#costContract_div9"];
  function setViewName(name) {
    for (var i = 0; i < dataView.length; i++) {
      if (name == dataView[i]) {
        $(name).css("display", "block");
      }
      else {
        $(dataView[i]).css("display", "none");
      }
    }
  }

  var optsC = {
    //terrace显示全部，card分页显示
    skin: "card",
    //renderer:"grid",
    columns: [
      { id: "contractLineid", name: "id", type: "ro", width: "100", hidden: true },
      { id: "contractNo", name: "合同编号", type: "ro" },
      { id: "contractName", name: "合同名称", type: "ro" },
      { id: "receivableCode", name: "应收方编号", type: "ro" },
      { id: "receivableName", name: "应收方名称", type: "ro" },
      { id: "feetypecode", name: "<span style='color:#096dd9;'>费用项目编号</span>", type: "ed" },
      { id: "feetypename", name: "费用项目名称", type: "ro" },
      { id: "feeruleName", name: "<span style='color:#096dd9;'>规则名称</span>", type: "ed" },
      { id: "memo", name: "<span style='color:#096dd9;'>备注</span>", type: "ed" },
      { id: "feetypeid", name: "费用项目id", type: "ro", hidden: true },
      { id: "feeruleId", name: "费用规则id", type: "ro", hidden: true },
      { id: "dataType", name: "类型", type: "ro", hidden: true }
    ],
    multiselect: false,
    toolbar: [
      { type: "settings", labelWidth: 90, labelAlign: "right" },
      {
        type: "row",
        list: [
          { type: "input", name: "contractNo", label: "合同编号:", className: "layui-col-md3", validate: "NotEmpty", required: true },
          { type: "input", name: "contractName", label: "合同名称:", className: "layui-col-md3", validate: "NotEmpty", required: true },
          {
            className: "layui-col-md3",
            type: "selectTable",
            placeholder: "请选择应收方",
            readonly: false,
            table: userTable,
            tableWidth: 500,
            tableHeight: 400,
            fieldText: "companyname",
            fieldValue: "companyid",
            name: "receivableIdFrom",
            label: "应收方:<span class='dhxform_item_required'>*</span>",
            listener: function (consignorGrid) {
              setMethod(consignorGrid, userTable, function (data) {
                var datad = {};
                datad.receivableCode = data.companycode;
                datad.receivableId = data.companyid;
                datad.receivableName = data.companyname;
                gridC.getToolBarForm().setFormData(datad);
                gridC.getGrid().clearAll();
              });
            }
          },
          { type: "input", name: "receivableId", label: "应收方id:", hidden: true },
          { type: "input", name: "receivableCode", label: "应收方bh:", hidden: true },
          { type: "input", name: "receivableName", label: "应收方mc:", hidden: true },
          {
            className: "layui-col-md3",
            type: "selectTable",
            placeholder: "请选择应付方",
            readonly: false,
            table: userTable,
            tableWidth: 500,
            tableHeight: 400,
            fieldText: "companyname",
            fieldValue: "companyid",
            name: "payableIdFrom",
            label: "应付方:<span class='dhxform_item_required'>*</span>",
            listener: function (consignorGrid) {
              setMethod(consignorGrid, userTable, function (data) {
                var datad = {};
                datad.payableCode = data.companycode;
                datad.payableId = data.companyid;
                datad.payableName = data.companyname;
                gridC.getToolBarForm().setFormData(datad);
                gridC.getGrid().clearAll();
              });
            }
          },
          { type: "input", name: "payableId", label: "应付方id:", hidden: true },
          { type: "input", name: "payableCode", label: "应付方bh:", hidden: true },
          { type: "input", name: "payableName", label: "应付方mc:", hidden: true }
        ]
      },
      {
        type: "row",
        list: [
          { type: "calendar", name: "contractdateFrom", label: "开始时间:", className: "layui-col-md3", required: true },
          { type: "calendar", name: "contractdateTo", label: "结束时间:", className: "layui-col-md3", required: true },
          { type: "calendar", name: "contractdatePostpone", label: "顺延时间:", className: "layui-col-md3" },
          { type: "input", name: "receivablePerson", label: "应收联系人:", className: "layui-col-md3" }
        ]
      },
      {
        type: "row",
        list: [
          { type: "input", name: "payablePerson", label: "应付联系人:", className: "layui-col-md3" },
          { type: "input", name: "memo", label: "备注:", className: "layui-col-md3" },
          {
            type: "block", className: "layui-col-md6 right",
            list: [
              { type: "button", className: "btn-normal", name: "addBtn", offsetLeft: 10, value: "<i class='layui-icon layui-icon-add-1'></i>新增" },
              { type: "newcolumn" },
              { type: "button", name: "delete", className: "normal", value: "删除" }
            ]
          }
        ]
      }
    ],

    url: UPCLOUD_RDC_TMS_BUSINESS_SERVICE+"/bmsFeeContract/queryBmsFeeContractItem",//数据接口
    type: "post",//数据提交方式，默认为get
    contentType: "application/json",
    params: "{}",//查询提交参数，分页参数默认为pageNum,pageSize
    page: false, //是否启用分页
    totalCount: "totalCount" //总记录数字段，默认totalCount
  };
  //分页参数 pageSize pageNum
  gridC = new PlgGrid(optsC);
  function setFromView() {
    gridC.renderTo("costContract_div4");
    gridC.getGrid().enableEditEvents(true, false, true);
    //按钮添加方法
    gridC.attachToolBarEvent("onButtonClick", function (name) {
      //新增
      if (name == "addBtn") {
        let id = Math.random();
        let data = gridC.getToolBarForm().getFormData();
        if (data.contractNo == "" || data.contractNo == null) {
          layer.msg("合同编号不能为空");
          return;
        }
        if (data.contractName == "" || data.contractName == null) {
          layer.msg("合同名称不能为空");
          return;
        }
        if (data.receivableCode == "" || data.receivableCode == null) {
          layer.msg("应收方不能为空");
          return;
        }
        var datad = {
          contractNo: data.contractNo,
          contractName: data.contractName,
          receivableCode: data.receivableCode,
          receivableName: data.receivableName,
          dataType: "GJzs"
        };
        gridC.addRow(id, datad);
      }
      //删除
      if (name == "delete") {
        let dataD = gridC.getToolBarForm().getFormData();
        var data1 = gridC.getSelectedRowId();
        if (data1 == null || data1 == "") {
          PlgDialog.msg("请选择一行");
          return;
        }
        let datad = gridC.getRowData(data1);
        if (datad.GJzs == "GJzs") {
          gridC.getGrid().deleteSelectedRows();
        }
        else {
          data1 = JSON.stringify([data1]);
          utilDelete(UPCLOUD_RDC_TMS_BUSINESS_SERVICE+"/bmsFeeContract/bmsFeeContractItemDel", "post", data1, function (data) {
                let rdata = JSON.stringify({ "contractId": dataD.contractId, "pageNum": "1", "pageSize": "10" });
            setMinList(gridC, rdata, dataD);
          }, "application/json");
        }
      }
    });

    //离开事件
    gridC.attachEvent("onEditCell", function (stage, rId, cInd, nValue) {
      //费用规则
      if (cInd == 8 && stage == 1) {
        getEject(ruleTable, "100", "400", (data) => {
          gridC.setCellValue(rId, cInd, data.feeRuleName);
          gridC.setCellValue(rId, 11, data.feeRuleId);
          layer.closeAll();
        });
      }
      //费用项目
      if (cInd == 6 && stage == 1) {
        getEject(objectTable, "100", "400", (data) => {
          gridC.setCellValue(rId, cInd, data.feetypecode);
          gridC.setCellValue(rId, 7, data.feetypename);
          gridC.setCellValue(rId, 10, data.feetypeid);
          layer.closeAll();
        });
      }
      if (stage == 2) {
        gridC.setCellValue(rId, cInd, nValue);
      }
      return true;
    });
    let inputs = $("#costContract_div4")[0].getElementsByTagName("input");
    $(inputs[0]).on("input propertychange", () => {
      gridC.getGrid().clearAll();
    });
    $(inputs[1]).on("input propertychange", () => {
      gridC.getGrid().clearAll();
    });
  }
  //返回
  $(".back-link").on("click", () => {
    setViewName("#costContract_div3");
  });
  //保存
  $("#costContract_save").on("click", () => {
    //数据data
    var data = gridC.getToolBarForm().getFormData();
    data.contractdateFrom = FormatDate(data.contractdateFrom);
    data.contractdateTo = FormatDate(data.contractdateTo);
    data.contractdatePostpone = FormatDate(data.contractdatePostpone);
    var feik = gridC.getToolBarForm().validate();
    if (!feik) {
      return;
    }
    if (!data.receivableId) {
      PlgDialog.msg("请选择应收方！");
      return;
    }
    if (!data.payableId) {
      PlgDialog.msg("请选择应付方！");
      return;
    }
    if (data.receivableId === data.payableId) {
      PlgDialog.msg("应收方、应付方信息不能相同！");
      return;
    }
    delete data.receivableIdFrom;
    delete data.payableIdFrom;
    var length = gridC.getGrid().getRowsNum();
    if (length == 0) {
      PlgDialog.msg("请添加明细！");
      return;
    }
    let MinListD = [];
    for (var i = 0; i < length; i++) {
      let rd = gridC.getRowData(gridC.getRowId(i));
      if (!rd.feetypecode) {
        layer.msg("请选择费用项目");
        return false;
      }
      if (!rd.feeruleName) {
        layer.msg("请输入规则名称");
        return false;
      }
      MinListD.push(rd);
    }
    //请求地址和类型
    var url = UPCLOUD_RDC_TMS_BUSINESS_SERVICE+"/bmsFeeContract/bmsFeeContractUpdate";
    var type = "post";
    var contentType = "application/json";
    //message新增为0，修改为1
    if (data.contractId == null || data.contractId == "") {
      url = UPCLOUD_RDC_TMS_BUSINESS_SERVICE+"/bmsFeeContract/bmsFeeContractSave";
    }
    let DataItem = JSON.stringify({ bmsFeeContractVo: data, list: MinListD });
    //调用ajax方法
    utilAjaxGJ(url, type, DataItem, function (data) {

      setViewName("#costContract_div3");
      grid.reload();
    }, contentType);
  });
};
