/**
|
* 初始化城市管理详情对话框
|
*/
|
var TOpenCityInfoDlg = {
|
tOpenCityInfoData : {},
|
editor: null,
|
validateFields: {
|
areaCode: {
|
validators: {
|
notEmpty: {
|
message: '请选择省'
|
}
|
}
|
}
|
}
|
};
|
|
/**
|
* 验证数据是否为空
|
*/
|
TOpenCityInfoDlg.validate = function () {
|
$('#openCityForm').data("bootstrapValidator").resetForm();
|
$('#openCityForm').bootstrapValidator('validate');
|
return $("#openCityForm").data('bootstrapValidator').isValid();
|
};
|
|
|
/**
|
* 清除数据
|
*/
|
TOpenCityInfoDlg.clearData = function() {
|
this.tOpenCityInfoData = {};
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TOpenCityInfoDlg.set = function(key, val) {
|
this.tOpenCityInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TOpenCityInfoDlg.get = function(key) {
|
return $("#" + key).val();
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
TOpenCityInfoDlg.close = function() {
|
parent.layer.close(window.parent.TOpenCity.layerIndex);
|
}
|
|
/**
|
* 收集数据
|
*/
|
TOpenCityInfoDlg.collectData = function() {
|
this
|
.set('id')
|
.set('areaCode')
|
.set('cityCode')
|
.set('provinceCode')
|
}
|
|
|
TOpenCityInfoDlg.openAddTextPrice = function () {
|
var index = layer.open({
|
type: 2,
|
title: '添加出租车价格',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tSystemPrice/taxi?price=' + $('#zc_price').val()
|
});
|
this.layerIndex = index;
|
};
|
|
|
TOpenCityInfoDlg.openAddTZCPrice = function (id){
|
var index = layer.open({
|
type: 2,
|
title: '添加专车价格',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tSystemPrice/tSystemPrice_add?id=' + id + "&price=" + $('#' + id).val()
|
});
|
this.layerIndex = index;
|
}
|
|
|
|
|
/**
|
* 提交添加
|
*/
|
TOpenCityInfoDlg.addSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
var zcArr=[];
|
$("#coun tr").each(function () {
|
var value = $(this).find("input[name='price']").val();
|
if('' != value && null != value){
|
zcArr.push(JSON.parse(atob(value)))
|
}
|
});
|
if(zcArr.length == 0){
|
Feng.error("请配置专车价格")
|
return;
|
}
|
|
console.log(zcArr);
|
var zczArr = $('#zc_price').val();
|
if(null == zczArr || zczArr == ''){
|
Feng.error("请配置出租车价格")
|
return;
|
}
|
if(null != this.tOpenCityInfoData.areaCode && '' != this.tOpenCityInfoData.areaCode){
|
this.tOpenCityInfoData.areaName = $('#areaCode').find('option:selected').text();
|
}
|
if(null != this.tOpenCityInfoData.cityCode && '' != this.tOpenCityInfoData.cityCode){
|
this.tOpenCityInfoData.cityName = $('#cityCode').find('option:selected').text();
|
}
|
if(null != this.tOpenCityInfoData.provinceCode && '' != this.tOpenCityInfoData.provinceCode){
|
this.tOpenCityInfoData.provinceName = $('#provinceCode').find('option:selected').text();
|
}
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tSystemPrice/add", function(data){
|
Feng.success("添加成功!");
|
window.parent.TOpenCity.table.refresh();
|
TOpenCityInfoDlg.close();
|
},function(data){
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tOpenCityInfoData);
|
ajax.set("zcPrice",JSON.stringify(zcArr));
|
ajax.set("czcPrice", atob(zczArr));
|
ajax.start();
|
}
|
|
/**
|
* 提交修改
|
*/
|
TOpenCityInfoDlg.editSubmit = function() {
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
var zcArr=[];
|
$("#coun tr").each(function () {
|
var value = $(this).find("input[name='price']").val();
|
if('' != value && null != value){
|
zcArr.push(JSON.parse(atob(value)))
|
}
|
});
|
if(zcArr.length == 0){
|
Feng.error("请配置专车价格")
|
return;
|
}
|
|
console.log(zcArr);
|
var zczArr = $('#zc_price').val();
|
if(null == zczArr || zczArr == ''){
|
Feng.error("请配置出租车价格")
|
return;
|
}
|
if(null != this.tOpenCityInfoData.areaCode && '' != this.tOpenCityInfoData.areaCode){
|
this.tOpenCityInfoData.areaName = $('#areaCode').find('option:selected').text();
|
}
|
if(null != this.tOpenCityInfoData.cityCode && '' != this.tOpenCityInfoData.cityCode){
|
this.tOpenCityInfoData.cityName = $('#cityCode').find('option:selected').text();
|
}
|
if(null != this.tOpenCityInfoData.provinceCode && '' != this.tOpenCityInfoData.provinceCode){
|
this.tOpenCityInfoData.provinceName = $('#provinceCode').find('option:selected').text();
|
}
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tSystemPrice/update", function(data){
|
Feng.success("修改成功!");
|
window.parent.TOpenCity.table.refresh();
|
TOpenCityInfoDlg.close();
|
},function(data){
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tOpenCityInfoData);
|
ajax.set("zcPrice",JSON.stringify(zcArr));
|
ajax.set("czcPrice", atob(zczArr));
|
ajax.start();
|
}
|
|
$(function() {
|
Feng.initValidator("openCityForm", TOpenCityInfoDlg.validateFields);
|
});
|
|
/**
|
* 省改变时执行
|
*/
|
TOpenCityInfoDlg.provinceChange = function () {
|
var provinceId = $("#areaCode").val();
|
var ajax = new $ax(Feng.ctxPath + "/tOpenCity/change", function(data){
|
if(data!=null){
|
var content='<option value="">选择市</option>';
|
$.each(data, function(k,v) {
|
content += "<option value='"+v.id+"'>"+v.name+"</option>";
|
});
|
$("#cityCode").empty().append(content);
|
$("#provinceCode").empty().append('<option value="">选择区</option>');
|
}
|
});
|
ajax.set("id",provinceId);
|
ajax.start();
|
}
|
/**
|
* 市改变时执行
|
*/
|
TOpenCityInfoDlg.cityChange = function () {
|
var cityId = $("#cityCode").val();
|
var ajax = new $ax(Feng.ctxPath + "/tOpenCity/change", function(data){
|
if(data!=null){
|
var content='<option value="">选择区</option>';
|
$.each(data, function(k,v) {
|
content += "<option value='"+v.id+"'>"+v.name+"</option>";
|
});
|
$("#provinceCode").empty().append(content);
|
}
|
});
|
ajax.set("id",cityId);
|
ajax.start();
|
}
|
|
|
//获取当前时间,格式YYYY-MM-DD
|
function getNowFormatDate() {
|
var date = new Date();
|
var seperator1 = "-";
|
var year = date.getFullYear();
|
var month = date.getMonth() + 1;
|
var strDate = date.getDate();
|
if (month >= 1 && month <= 9) {
|
month = "0" + month;
|
}
|
if (strDate >= 0 && strDate <= 9) {
|
strDate = "0" + strDate;
|
}
|
var currentdate = year + seperator1 + month + seperator1 + strDate;
|
return currentdate;
|
}
|