/** * 初始化跨城站点管理详情对话框 */ var TLineInfoDlg = { tLineInfoData : {}, destinationLayerIndex: null, destinationEditRow: null, destinationMap: null, destinationMouseTool: null, destinationFenceOverlay: null, destinationDefaultPointMarker: null, destinationSelectPointMode: false, destinationAutoComplete: null, destinationPlaceSearch: null, validateFields: { name: { validators: { notEmpty: { message: '线路名称不能为空' } } }, startSiteId: { validators: { notEmpty: { message: '请选择起点' } } }, endSiteId: { validators: { notEmpty: { message: '请选择终点' } } }, shiftInterval: { validators: { notEmpty: { message: '司机申请限制分钟数不能为空' }, regexp: { regexp: /^[0-9]{0,3}$/, message: '司机申请限制分钟数格式不正确' } } }, rakeRate: { validators: { notEmpty: { message: '抽成比例不能为空' }, regexp: { regexp: /^([0-9]{1,2}$)|(^[0-9]{1,2}\.[0-9]{1,2}$)|100$/, message: '抽成比例格式不正确' } } }, } }; /** * 验证数据是否为空 */ TLineInfoDlg.validate = function () { $('#lineInfoForm').data("bootstrapValidator").resetForm(); $('#lineInfoForm').bootstrapValidator('validate'); return $("#lineInfoForm").data('bootstrapValidator').isValid(); }; /** * 清除数据 */ TLineInfoDlg.clearData = function() { this.tLineInfoData = {}; } /** * 设置对话框中的数据 * * @param key 数据的名称 * @param val 数据的具体值 */ TLineInfoDlg.set = function(key, val) { this.tLineInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val; return this; } /** * 设置对话框中的数据 * * @param key 数据的名称 * @param val 数据的具体值 */ TLineInfoDlg.get = function(key) { return $("#" + key).val(); } /** * 关闭此对话框 */ TLineInfoDlg.close = function() { parent.layer.close(window.parent.TLine.layerIndex); } TLineInfoDlg.set1 = function (e) { console.log("---------------"+e) let index = layer.open({ type: 2, title: '抽成设置', area: ['80%', '80%'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/tLine/set/'+e }); this.layerIndex = index; }; TLineInfoDlg.set2 = function (e) { console.log("---------------"+e) let index = layer.open({ type: 2, title: '抽成设置', area: ['80%', '80%'], //宽高 fix: false, //不固定 maxmin: true, content: Feng.ctxPath + '/tLine/set1/'+e }); this.layerIndex = index; }; /** * 收集数据 */ TLineInfoDlg.collectData = function() { this .set('id') .set('name') .set('shiftInterval') .set('dispatchPhone') .set('rakeRate') .set('state') .set('insertTime') .set('outSetting'); } TLineInfoDlg.validateOutSetting = function () { var outSetting = $("#outSetting").val(); if (!outSetting) { Feng.error("请设置司机抽成"); return false; } try { var config = JSON.parse(outSetting); if (config.rules && config.rules.length > 0) { for (var i = 0; i < config.rules.length; i++) { if (config.rules[i].percent !== undefined && config.rules[i].percent !== "") { return true; } } } if (config.time_rules && config.time_rules.length > 0) { for (var j = 0; j < config.time_rules.length; j++) { var rules = config.time_rules[j]; if (!rules || rules.length <= 0) { continue; } for (var k = 0; k < rules.length; k++) { if (rules[k].percent !== undefined && rules[k].percent !== "") { return true; } } } } } catch (e) { Feng.error("司机抽成配置格式不正确"); return false; } Feng.error("请设置司机抽成"); return false; } /** * 提交添加 */ TLineInfoDlg.addSubmit = function(e) { this.clearData(); this.collectData(); if(!this.validate()){ return ; } if(!TLineInfoDlg.validateOutSetting()){ return ; } var startSiteId = $("#startSiteId").val(); var endSiteId = $("#endSiteId").val(); if(!TLineInfoDlg.validateShiftCarNum()){ return; } var shuArr=[]; $(".shiftValueClass").each(function () { shuArr.push({ shiftTime:$(this).find("input[name*='shiftTimeValue']").val(), carNum:$(this).find("input[name*='carNumValue']").val(), time2:$(this).find("input[name*='time2Value']").val(), }) }) if(shuArr.length <= 0){ Feng.error("请至少设置一条班次设置"); return; } var destArr = TLineInfoDlg.collectDestinationArr(); if(destArr === false){ return; } $(e).attr('disabled','disabled'); //点击后就禁用,若想再次点击需刷新页面; //提交信息 var ajax = new $ax(Feng.ctxPath + "/tLine/add", function(data){ $(e).removeAttr('disabled'); if(data.status == 200){ Feng.success("添加成功!"); window.parent.TLine.table.refresh(); TLineInfoDlg.close(); }else{ Feng.error(data.msg); } },function(data){ Feng.error("添加失败!" + data.responseJSON.message + "!"); }); ajax.set(this.tLineInfoData); ajax.set("startSiteId",startSiteId); ajax.set("endSiteId",endSiteId); ajax.set("subArr","[]"); ajax.set("shuArr",JSON.stringify(shuArr)); ajax.set("destArr",JSON.stringify(destArr)); ajax.start(); } /** * 提交修改 */ TLineInfoDlg.editSubmit = function() { this.clearData(); this.collectData(); if(!this.validate()){ return ; } if(!TLineInfoDlg.validateOutSetting()){ return ; } var startSiteId = $("#startSiteId").val(); var endSiteId = $("#endSiteId").val(); if(!TLineInfoDlg.validateShiftCarNum()){ return; } var shuArr=[]; $(".shiftValueClass").each(function () { shuArr.push({ shiftTime:$(this).find("input[name*='shiftTimeValue']").val(), carNum:$(this).find("input[name*='carNumValue']").val(), time2:$(this).find("input[name*='time2Value']").val(), }) }) if(shuArr.length <= 0){ Feng.error("请至少设置一条班次设置"); return; } var destArr = TLineInfoDlg.collectDestinationArr(); if(destArr === false){ return; } //提交信息 var ajax = new $ax(Feng.ctxPath + "/tLine/update", function(data){ if(data.status == 200){ Feng.success("修改成功!"); window.parent.TLine.table.refresh(); TLineInfoDlg.close(); }else{ Feng.error(data.msg); } },function(data){ Feng.error("修改失败!" + data.responseJSON.message + "!"); }); ajax.set(this.tLineInfoData); ajax.set("startSiteId",startSiteId); ajax.set("endSiteId",endSiteId); ajax.set("subArr","[]"); ajax.set("shuArr",JSON.stringify(shuArr)); ajax.set("destArr",JSON.stringify(destArr)); ajax.start(); } //添加公司提交 TLineInfoDlg.addCompanySubmit = function(){ var comArr=[]; $(".companyValueClass").each(function () { comArr.push({ companyId:$(this).find("input[name*='companyIdValue']").val(), }) }) /*if(comArr.length <= 0){ Feng.error("请至少添加一个企业"); return; }*/ //提交信息 var ajax = new $ax(Feng.ctxPath + "/tLine/addCompany", function(data){ Feng.success("操作成功!"); window.parent.TLine.table.refresh(); TLineInfoDlg.close(); },function(data){ Feng.error("操作失败!" + data.responseJSON.message + "!"); }); ajax.set("lineId",$("#lineId").val()); ajax.set("comArr",JSON.stringify(comArr)); ajax.start(); } $(function() { Feng.initValidator("lineInfoForm", TLineInfoDlg.validateFields); }); /** * 添加班次 */ TLineInfoDlg.addShift = function () { var shiftTime = $("#shiftTime").val(); if ("" == shiftTime){ Feng.info("请选择班次时间区间"); return; } var carNum = $("#carNum").val(); if ("" == carNum){ Feng.info("请填写车次数"); return; }else if (!regInt.test(carNum)){ Feng.info("车次数格式不正确"); return; }else if (parseInt(carNum, 10) <= 0){ Feng.info("车次数必须为正整数"); return; } times = shiftTime.split(" - "); var time1 = times[0]; var time2 = times[1]; if (time1 >= time2) { Feng.info("开始时间不能大于结束时间"); return; } var shuArr=[]; $(".shiftValueClass").each(function () { shuArr.push({ shiftTime:$(this).find("input[name*='shiftTimeValue']").val(), carNum:$(this).find("input[name*='carNumValue']").val(), time2:$(this).find("input[name*='time2Value']").val(), }) }) //判断时间是否存在 for(var i=0;i' + getNowFormatDate() + '' + ''+shiftTime+'' + '' + '' + '' + '' + '' + '' + ''; $("#shiftValue").append(str); } TLineInfoDlg.normalizePositiveInt = function (numStr) { var onlyNum = (numStr || "").replace(/[^\d]/g, ""); onlyNum = onlyNum.replace(/^0+/, ""); return onlyNum; } TLineInfoDlg.syncCarNumValue = function (input) { var $input = $(input); var value = TLineInfoDlg.normalizePositiveInt($input.val()); $input.val(value); $input.closest("td").find("input[name='carNumValue']").val(value); } TLineInfoDlg.onCarNumInput = function (input) { TLineInfoDlg.syncCarNumValue(input); } TLineInfoDlg.onCarNumBlur = function (input) { var $input = $(input); var value = TLineInfoDlg.normalizePositiveInt($input.val()); if (value == "" || parseInt(value, 10) <= 0) { value = "1"; } $input.val(value); $input.closest("td").find("input[name='carNumValue']").val(value); } TLineInfoDlg.changeCarNum = function (btn, step) { var $td = $(btn).closest("td"); var $input = $td.find("input[name='carNumEditValue']"); var value = TLineInfoDlg.normalizePositiveInt($input.val()); var num = parseInt(value, 10); if (isNaN(num) || num <= 0) { num = 1; } num = num + step; if (num <= 0) { num = 1; } $input.val(num); $td.find("input[name='carNumValue']").val(num); } TLineInfoDlg.validateShiftCarNum = function () { var valid = true; $(".shiftValueClass").each(function () { var $row = $(this); var $editInput = $row.find("input[name='carNumEditValue']"); if ($editInput.length > 0) { TLineInfoDlg.onCarNumBlur($editInput[0]); } var carNum = $row.find("input[name*='carNumValue']").val(); if (!/^[1-9]\d*$/.test(carNum)) { valid = false; return false; } }); if (!valid) { Feng.error("班次车次数必须为正整数"); } return valid; } TLineInfoDlg.toMinutes = function (timeStr) { var arr = timeStr.split(":"); return parseInt(arr[0], 10) * 60 + parseInt(arr[1], 10); } TLineInfoDlg.toTimeStr = function (minutes) { var h = Math.floor(minutes / 60); var m = minutes % 60; return (h < 10 ? "0" + h : "" + h) + ":" + (m < 10 ? "0" + m : "" + m); } /** * 批量生成班次 * 规则: * 第一次:始发时间 - 始发时间+间隔 * 后续:上次后段时间 - 后段时间+间隔 */ TLineInfoDlg.generateShiftList = function () { var firstShiftTime = $("#firstShiftTime").val(); var lastShiftTime = $("#lastShiftTime").val(); var shiftGap = $("#shiftGap").val(); var batchCarNum = $("#batchCarNum").val(); if (firstShiftTime == "") { Feng.info("请选择始发时间"); return; } if (lastShiftTime == "") { Feng.info("请选择末班时间"); return; } if (shiftGap == "") { Feng.info("请选择间隔时间"); return; } if (batchCarNum == "") { Feng.info("请填写每班车次数"); return; } if (!regInt.test(batchCarNum)) { Feng.info("车次数格式不正确"); return; } if (parseInt(batchCarNum, 10) <= 0) { Feng.info("车次数必须为正整数"); return; } var startMinute = TLineInfoDlg.toMinutes(firstShiftTime); var lastMinute = TLineInfoDlg.toMinutes(lastShiftTime); var gap = parseInt(shiftGap, 10); if (startMinute > lastMinute) { Feng.info("始发时间不能大于末班时间"); return; } var existsMap = {}; $(".shiftValueClass").each(function () { var shiftTimeValue = $(this).find("input[name*='shiftTimeValue']").val(); if (shiftTimeValue) { shiftTimeValue = shiftTimeValue.replace(/\s+/g, ""); } existsMap[shiftTimeValue] = true; }); var currentStart = startMinute; var generated = 0; var duplicate = 0; while (currentStart <= lastMinute) { var currentEnd = currentStart + gap; if (currentEnd > 24 * 60) { break; } var shiftTime = TLineInfoDlg.toTimeStr(currentStart) + " - " + TLineInfoDlg.toTimeStr(currentEnd); var shiftTimeKey = shiftTime.replace(/\s+/g, ""); if (!existsMap[shiftTimeKey]) { TLineInfoDlg.appendShiftRow(shiftTime, batchCarNum); existsMap[shiftTimeKey] = true; generated++; } else { duplicate++; } currentStart = currentEnd; } if (generated == 0) { Feng.info("未生成新班次,班次时间可能已存在"); return; } if (duplicate > 0) { Feng.success("已生成" + generated + "条班次,跳过重复" + duplicate + "条"); } else { Feng.success("已生成" + generated + "条班次"); } } TLineInfoDlg.collectDestinationArr = function () { var destArr = []; var mainCount = 0; $(".destinationValueClass").each(function () { var item = { time: $(this).find("input[name='destinationTimeValue']").val(), fenceType: $(this).find("input[name='destinationFenceTypeValue']").val(), coordinate: $(this).find("input[name='destinationCoordinateValue']").val(), defaultPointLon: $(this).find("input[name='destinationDefaultPointLonValue']").val(), defaultPointLat: $(this).find("input[name='destinationDefaultPointLatValue']").val(), name: $(this).find("input[name='destinationNameValue']").val(), price5: $(this).find("input[name='destinationPrice5Value']").val(), price7: $(this).find("input[name='destinationPrice7Value']").val(), state: $(this).find("input[name='destinationStateValue']").val(), isMain: $(this).find("input[name='destinationIsMainValue']").val() }; if (item.isMain == "1") { mainCount++; } destArr.push(item); }); if (destArr.length <= 0) { Feng.error("请至少设置一个目的地"); return false; } if (mainCount > 1) { Feng.error("最多只能设置一个主要目的地"); return false; } return destArr; } TLineInfoDlg.escapeHtml = function (str) { return (str || "").replace(/&/g, "&").replace(//g, ">"); } TLineInfoDlg.escapeAttr = function (str) { return TLineInfoDlg.escapeHtml(str).replace(/"/g, """); } TLineInfoDlg.openDestinationDialog = function () { if ($(".destinationValueClass").length >= 3) { Feng.error("最多只能添加3个目的地"); return; } TLineInfoDlg.destinationEditRow = null; TLineInfoDlg.resetDestinationForm(); TLineInfoDlg.openDestinationLayer("添加目的地"); } TLineInfoDlg.openDestinationLayer = function (title) { TLineInfoDlg.destinationLayerIndex = layer.open({ type: 1, title: title, area: ['1000px', '760px'], btn: ['保存', '取消'], content: $("#destinationDialogContent"), success: function () { $("#destinationDialogContent").show(); TLineInfoDlg.initDestinationMap(); setTimeout(function () { if (TLineInfoDlg.destinationMap) { TLineInfoDlg.destinationMap.resize(); TLineInfoDlg.destinationMap.setFitView(); } }, 100); }, yes: function (index) { TLineInfoDlg.saveDestination(index); }, end: function () { $("#destinationDialogContent").hide(); TLineInfoDlg.destinationSelectPointMode = false; if (TLineInfoDlg.destinationMouseTool) { TLineInfoDlg.destinationMouseTool.close(); } } }); } TLineInfoDlg.resetDestinationForm = function () { $("#destinationEditIndex").val(""); $("#destinationName").val(""); $("#destinationPrice5").val(""); $("#destinationPrice7").val(""); $("#destinationAddressKeyword").val(""); $("#destinationCoordinate").val(""); $("#destinationDefaultPointLon").val(""); $("#destinationDefaultPointLat").val(""); $("#destinationDefaultPointText").text(""); $("#destinationFenceType1").prop("checked", true); $("#destinationState1").prop("checked", true); $("#destinationIsMain0").prop("checked", true); TLineInfoDlg.destinationFenceTypeChange(1); TLineInfoDlg.clearDestinationFence(); } TLineInfoDlg.destinationFenceTypeChange = function (type) { if (type == 1) { $("#destinationFenceTip").text("圆形围栏默认点为圆心"); } else { $("#destinationFenceTip").text("多边形围栏需要确认一个默认点"); } } TLineInfoDlg.initDestinationMap = function () { if (TLineInfoDlg.destinationMap) { return; } TLineInfoDlg.destinationMap = new AMap.Map("destinationMapContainer", { resizeEnable: true, zoom: 13 }); TLineInfoDlg.destinationMouseTool = new AMap.MouseTool(TLineInfoDlg.destinationMap); TLineInfoDlg.destinationMouseTool.on('draw', function (e) { var type = $("input[name='destinationFenceType']:checked").val(); TLineInfoDlg.clearDestinationFence(); TLineInfoDlg.destinationFenceOverlay = e.obj; if (type == "1") { var center = e.obj.getCenter(); var radius = e.obj.getRadius(); if (radius > 5000) { Feng.error("圆形围栏半径不能大于5000米"); TLineInfoDlg.clearDestinationFence(); return; } var coordinate = center.lng + "," + center.lat + ";" + radius; $("#destinationCoordinate").val(coordinate); $("#destinationDefaultPointLon").val(center.lng); $("#destinationDefaultPointLat").val(center.lat); TLineInfoDlg.setDestinationDefaultPointMarker(center.lng, center.lat, true); } else { var path = e.obj.getPath(); var coordinate = TLineInfoDlg.pathToCoordinate(path); $("#destinationCoordinate").val(coordinate); } }); TLineInfoDlg.destinationMap.on('click', function (e) { if (!TLineInfoDlg.destinationSelectPointMode) { return; } var fenceType = $("input[name='destinationFenceType']:checked").val(); if (fenceType != "2") { Feng.info("圆形围栏默认点为圆心,无需单独设置"); TLineInfoDlg.destinationSelectPointMode = false; return; } $("#destinationDefaultPointLon").val(e.lnglat.getLng()); $("#destinationDefaultPointLat").val(e.lnglat.getLat()); TLineInfoDlg.setDestinationDefaultPointMarker(e.lnglat.getLng(), e.lnglat.getLat(), false); TLineInfoDlg.destinationSelectPointMode = false; Feng.success("默认点设置成功"); }); TLineInfoDlg.destinationAutoComplete = new AMap.Autocomplete({ city: "", input: "destinationAddressKeyword" }); TLineInfoDlg.destinationPlaceSearch = new AMap.PlaceSearch({ map: TLineInfoDlg.destinationMap, pageSize: 1, pageIndex: 1, citylimit: false }); AMap.event.addListener(TLineInfoDlg.destinationAutoComplete, "select", function (e) { if (!e.poi || !e.poi.location) { return; } var lon = e.poi.location.lng; var lat = e.poi.location.lat; TLineInfoDlg.destinationMap.setCenter([lon, lat]); TLineInfoDlg.destinationMap.setZoom(15); $("#destinationDefaultPointLon").val(lon); $("#destinationDefaultPointLat").val(lat); TLineInfoDlg.setDestinationDefaultPointMarker(lon, lat, false); }); } TLineInfoDlg.searchDestinationAddress = function () { var keyword = $("#destinationAddressKeyword").val(); if (!keyword) { Feng.info("请输入地址关键词"); return; } if (!TLineInfoDlg.destinationPlaceSearch) { return; } TLineInfoDlg.destinationPlaceSearch.search(keyword, function (status, result) { if (status !== "complete" || !result || !result.poiList || result.poiList.count <= 0) { Feng.error("未找到相关地址"); return; } var poi = result.poiList.pois[0]; if (!poi || !poi.location) { Feng.error("地址定位失败"); return; } var lon = poi.location.lng; var lat = poi.location.lat; TLineInfoDlg.destinationMap.setCenter([lon, lat]); TLineInfoDlg.destinationMap.setZoom(15); $("#destinationDefaultPointLon").val(lon); $("#destinationDefaultPointLat").val(lat); TLineInfoDlg.setDestinationDefaultPointMarker(lon, lat, false); }); } TLineInfoDlg.pathToCoordinate = function (path) { var arr = []; for (var i = 0; i < path.length; i++) { arr.push(path[i].lng + "," + path[i].lat); } return arr.join(";"); } TLineInfoDlg.selectDestinationDefaultPoint = function () { var fenceType = $("input[name='destinationFenceType']:checked").val(); if (fenceType == "1") { Feng.info("圆形围栏默认点为圆心,无需单独设置"); return; } TLineInfoDlg.destinationSelectPointMode = true; Feng.info("请在地图上点击设置默认点"); } TLineInfoDlg.startDrawDestinationFence = function () { TLineInfoDlg.initDestinationMap(); var type = $("input[name='destinationFenceType']:checked").val(); TLineInfoDlg.clearDestinationFence(); if (type == "1") { TLineInfoDlg.destinationMouseTool.circle({ fillColor: '#00b0ff', strokeColor: '#80d8ff' }); } else { TLineInfoDlg.destinationMouseTool.polygon({ fillColor: '#00b0ff', strokeColor: '#80d8ff' }); } } TLineInfoDlg.clearDestinationFence = function (keepValue) { if (TLineInfoDlg.destinationFenceOverlay) { TLineInfoDlg.destinationMap.remove(TLineInfoDlg.destinationFenceOverlay); TLineInfoDlg.destinationFenceOverlay = null; } if (TLineInfoDlg.destinationDefaultPointMarker) { TLineInfoDlg.destinationMap.remove(TLineInfoDlg.destinationDefaultPointMarker); TLineInfoDlg.destinationDefaultPointMarker = null; } if (!keepValue) { $("#destinationCoordinate").val(""); $("#destinationDefaultPointLon").val(""); $("#destinationDefaultPointLat").val(""); } $("#destinationDefaultPointText").text(""); } TLineInfoDlg.setDestinationDefaultPointMarker = function (lon, lat, auto) { if (!TLineInfoDlg.destinationMap) { return; } if (TLineInfoDlg.destinationDefaultPointMarker) { TLineInfoDlg.destinationMap.remove(TLineInfoDlg.destinationDefaultPointMarker); } TLineInfoDlg.destinationDefaultPointMarker = new AMap.Marker({ map: TLineInfoDlg.destinationMap, position: new AMap.LngLat(lon, lat) }); var text = "默认点:" + lon + "," + lat; if (auto) { text += "(圆心)"; } $("#destinationDefaultPointText").text(text); } TLineInfoDlg.validateDestinationForm = function () { var name = $("#destinationName").val(); if (!name) { Feng.error("请填写目的地名称"); return false; } var priceReg = /^(0|[1-9]\d{0,6})(\.\d{1,2})?$/; var price5 = $("#destinationPrice5").val(); var price7 = $("#destinationPrice7").val(); if (!priceReg.test(price5)) { Feng.error("5座车费用格式不正确"); return false; } if (!priceReg.test(price7)) { Feng.error("7座车费用格式不正确"); return false; } var coordinate = $("#destinationCoordinate").val(); if (!coordinate) { Feng.error("请先设置目的地围栏"); return false; } var fenceType = $("input[name='destinationFenceType']:checked").val(); var defaultPointLon = $("#destinationDefaultPointLon").val(); var defaultPointLat = $("#destinationDefaultPointLat").val(); if (fenceType == "2" && (!defaultPointLon || !defaultPointLat)) { Feng.error("多边形围栏必须设置默认点"); return false; } if ($("input[name='destinationIsMain']:checked").val() == "1") { var sameMainCount = 0; $(".destinationValueClass").each(function () { if ($(this).find("input[name='destinationIsMainValue']").val() == "1") { if (!TLineInfoDlg.destinationEditRow || this != TLineInfoDlg.destinationEditRow[0]) { sameMainCount++; } } }); if (sameMainCount > 0) { Feng.error("已存在主要目的地,请先调整后再保存"); return false; } } return true; } TLineInfoDlg.saveDestination = function (layerIndex) { if (!TLineInfoDlg.validateDestinationForm()) { return; } var data = { time: getNowFormatDate(), fenceType: $("input[name='destinationFenceType']:checked").val(), coordinate: $("#destinationCoordinate").val(), defaultPointLon: $("#destinationDefaultPointLon").val(), defaultPointLat: $("#destinationDefaultPointLat").val(), name: $("#destinationName").val(), price5: $("#destinationPrice5").val(), price7: $("#destinationPrice7").val(), state: $("input[name='destinationState']:checked").val(), isMain: $("input[name='destinationIsMain']:checked").val() }; if (TLineInfoDlg.destinationEditRow) { TLineInfoDlg.destinationEditRow.replaceWith(TLineInfoDlg.buildDestinationRowHtml(data)); } else { $("#destinationValue").append(TLineInfoDlg.buildDestinationRowHtml(data)); } layer.close(layerIndex); } TLineInfoDlg.buildDestinationRowHtml = function (data) { var fenceTypeText = data.fenceType == "1" ? "圆形围栏" : "多边形围栏"; var stateText = data.state == "1" ? "启用" : "关闭"; var isMainText = data.isMain == "1" ? "是" : "否"; var nameHtml = TLineInfoDlg.escapeHtml(data.name); var coordinateAttr = TLineInfoDlg.escapeAttr(data.coordinate); var nameAttr = TLineInfoDlg.escapeAttr(data.name); return '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + fenceTypeText + '' + '' + nameHtml + '' + '' + TLineInfoDlg.escapeHtml(data.price5) + '' + '' + TLineInfoDlg.escapeHtml(data.price7) + '' + '' + stateText + '' + '' + isMainText + '' + '' + ' ' + '' + ''; } TLineInfoDlg.editDestination = function (btn) { var $row = $(btn).closest("tr"); TLineInfoDlg.destinationEditRow = $row; TLineInfoDlg.resetDestinationForm(); $("#destinationName").val($row.find("input[name='destinationNameValue']").val()); $("#destinationPrice5").val($row.find("input[name='destinationPrice5Value']").val()); $("#destinationPrice7").val($row.find("input[name='destinationPrice7Value']").val()); $("#destinationCoordinate").val($row.find("input[name='destinationCoordinateValue']").val()); $("#destinationDefaultPointLon").val($row.find("input[name='destinationDefaultPointLonValue']").val()); $("#destinationDefaultPointLat").val($row.find("input[name='destinationDefaultPointLatValue']").val()); var fenceType = $row.find("input[name='destinationFenceTypeValue']").val(); var state = $row.find("input[name='destinationStateValue']").val(); var isMain = $row.find("input[name='destinationIsMainValue']").val(); $("input[name='destinationFenceType'][value='" + fenceType + "']").prop("checked", true); $("input[name='destinationState'][value='" + state + "']").prop("checked", true); $("input[name='destinationIsMain'][value='" + isMain + "']").prop("checked", true); TLineInfoDlg.destinationFenceTypeChange(parseInt(fenceType, 10)); TLineInfoDlg.openDestinationLayer("编辑目的地"); setTimeout(function () { TLineInfoDlg.restoreDestinationMapFence(); }, 150); } TLineInfoDlg.restoreDestinationMapFence = function () { TLineInfoDlg.initDestinationMap(); TLineInfoDlg.clearDestinationFence(true); var fenceType = $("input[name='destinationFenceType']:checked").val(); var coordinate = $("#destinationCoordinate").val(); if (!coordinate) { return; } if (fenceType == "1") { var arr = coordinate.split(";"); if (arr.length != 2) { return; } var centerArr = arr[0].split(","); if (centerArr.length != 2) { return; } var center = new AMap.LngLat(parseFloat(centerArr[0]), parseFloat(centerArr[1])); var radius = parseFloat(arr[1]); TLineInfoDlg.destinationFenceOverlay = new AMap.Circle({ center: center, radius: radius, fillColor: '#00b0ff', strokeColor: '#80d8ff' }); TLineInfoDlg.destinationMap.add(TLineInfoDlg.destinationFenceOverlay); TLineInfoDlg.setDestinationDefaultPointMarker(center.getLng(), center.getLat(), true); TLineInfoDlg.destinationMap.setFitView(); } else { var pointsArr = coordinate.split(";"); var points = []; for (var i = 0; i < pointsArr.length; i++) { var point = pointsArr[i].split(","); if (point.length == 2) { points.push([parseFloat(point[0]), parseFloat(point[1])]); } } if (points.length > 0) { TLineInfoDlg.destinationFenceOverlay = new AMap.Polygon({ path: points, fillColor: '#00b0ff', strokeColor: '#80d8ff' }); TLineInfoDlg.destinationMap.add(TLineInfoDlg.destinationFenceOverlay); var lon = $("#destinationDefaultPointLon").val(); var lat = $("#destinationDefaultPointLat").val(); if (lon && lat) { TLineInfoDlg.setDestinationDefaultPointMarker(parseFloat(lon), parseFloat(lat), false); } TLineInfoDlg.destinationMap.setFitView(); } } } TLineInfoDlg.deleteDestination = function (btn) { $(btn).closest("tr").remove(); } /** * 添加公司 */ TLineInfoDlg.addCompany = function () { var companyId = $("#companyId").val(); var companyText = $("#companyId option:selected").text(); if ("" == companyId){ Feng.info("请选择企业"); return; } var comArr=[]; $(".companyValueClass").each(function () { comArr.push({ companyId:$(this).find("input[name*='companyIdValue']").val(), }) }) //判断公司是否存在 for(var i=0;i'+companyText+'' + ''; $("#companyValue").append(str); //清除数据 $("#companyId").val(""); } function deleteSub(e) { $(e).parent().parent().remove(); }