/**
|
* 初始化商家信息详情对话框
|
*/
|
var MemMerchantInfoDlg = {
|
memMerchantInfoData: {},
|
validFields: {
|
merchantName: Feng.def_valid_info(true), // 不能为空
|
imAccount: Feng.def_valid_info(true), // 不能为空
|
address: Feng.def_valid_info(true), // 不能为空
|
address: Feng.def_valid_info(true), // 不能为空
|
imPassword: Feng.def_valid_info(true), // 不能为空
|
startTime: Feng.def_valid_info(true), // 不能为空
|
cityId: Feng.def_valid_info(true), // 不能为空
|
idCard: Feng.def_valid_info(true), // 不能为空
|
workStartDate: Feng.def_valid_info(true), // 不能为空
|
workEndDate: Feng.def_valid_info(true), // 不能为空
|
workStartTime: Feng.def_valid_info(true), // 不能为空
|
workEndTime: Feng.def_valid_info(true), // 不能为空
|
aptitudeImg: Feng.def_valid_info(true), // 不能为空
|
permitImg: Feng.def_valid_info(true), // 不能为空
|
attachment: Feng.def_valid_info(true), // 不能为空
|
goodsIds: Feng.def_valid_info(true), // 不能为空
|
linkman: Feng.def_valid_info(true), // 不能为空
|
linkPosition: Feng.def_valid_info(true), // 不能为空
|
linkPhone: Feng.def_valid_info(true), // 不能为空
|
linkCard: Feng.def_valid_info(true), // 不能为空
|
}
|
};
|
|
/**
|
* 清除数据
|
*/
|
MemMerchantInfoDlg.clearData = function () {
|
this.memMerchantInfoData = {};
|
};
|
|
/**
|
* 设置对话框中的数据
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
MemMerchantInfoDlg.set = function (key, val) {
|
if(key =='serviceIds'){
|
var ser = $("#" + key).val();
|
if(ser!=null){
|
this.memMerchantInfoData[key] = ser.join()
|
}
|
}else if(key =='goodsIds') {
|
debugger
|
var trList = document.getElementById("product_tbody").getElementsByTagName("tr");
|
var product = [];
|
for(var ti = 0;ti < trList.length;ti++){
|
var productInfo = {};
|
var childrenList = trList[ti].getElementsByTagName("td")[11].getElementsByTagName("div")[0].children;
|
if($(childrenList[0]).is(":hidden")){
|
productInfo.state = $(childrenList[0]).val();
|
}
|
if ($(childrenList[childrenList.length - 1]).is(":hidden")) {
|
productInfo.goodsSkuId = $(
|
childrenList[childrenList.length - 1]).val();
|
} else {
|
productInfo.specIds = trList[ti].getElementsByTagName("td")[4].innerHTML;
|
}
|
productInfo.goodsId = trList[ti].getElementsByTagName("td")[0].innerHTML;
|
var price1 = trList[ti].getElementsByTagName("td")[8].innerHTML;
|
var price = trList[ti].getElementsByTagName("td")[10].getElementsByTagName("input");
|
productInfo.price = $(price[0]).val()?$(price[0]).val():price1;
|
product[ti] = productInfo;
|
}
|
this.memMerchantInfoData['productId'] = JSON.stringify(product);
|
this.memMerchantInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
}else {
|
this.memMerchantInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
}
|
return this;
|
};
|
|
/**
|
* 设置对话框中的数据
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
MemMerchantInfoDlg.get = function (key) {
|
return $("#" + key).val();
|
};
|
|
/**
|
* 关闭此对话框
|
*/
|
MemMerchantInfoDlg.close = function () {
|
parent.layer.close(window.parent.MemMerchant.layerIndex);
|
};
|
|
/**
|
* 收集数据
|
*/
|
MemMerchantInfoDlg.collectData = function () {
|
this
|
.set('id')
|
.set('merchantName') //门店名称
|
.set('imAccount') //登录账户
|
.set('address') //详细地址
|
.set('imPassword') //登录密码
|
.set('serviceIds')//门店服务
|
.set('startTime')//运营时间
|
.set('cityId')//省
|
.set('idCard')//统一社会信用号码/身份证
|
.set('workStartDate')//营业时间 开始
|
.set('workEndDate') //营业时间 结束
|
.set('workStartTime') //营业时间 开始 时间
|
.set('workEndTime') //营业时间 结束时间
|
.set('aptitudeImg')//运营资质
|
.set('permitImg')//营业执照
|
.set('attachment')//门店环境
|
.set('goodsIds')//管理商品
|
.set('linkman')//负责人
|
.set('linkPosition')//职位
|
.set('linkPhone')//联系电话
|
.set('linkCard')//身份证号码
|
;
|
};
|
|
/**
|
* 提交添加
|
*/
|
MemMerchantInfoDlg.addSubmit = function () {
|
this.clearData();
|
this.collectData();
|
console.log(this.memMerchantInfoData['permitImg'])
|
if( this.memMerchantInfoData['permitImg']=="" ){
|
Feng.error("营业执照不能为空!");
|
return;
|
}
|
if ( !Feng.check_form( "formId")) { return; }
|
|
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/memMerchant/add", function (data) {
|
if (data.code == 200) {
|
Feng.success("添加成功!");
|
window.parent.MemMerchant.table.refresh();
|
MemMerchantInfoDlg.close();
|
} else {
|
Feng.error("添加失败!" + data.message);
|
}
|
}, function () {
|
Feng.error("添加失败!");
|
});
|
ajax.set(this.memMerchantInfoData);
|
ajax.start();
|
};
|
|
/**
|
* 提交修改
|
*/
|
MemMerchantInfoDlg.editSubmit = function () {
|
this.clearData();
|
this.collectData();
|
|
if ( !Feng.check_form( "formId")) { return; }
|
if( this.memMerchantInfoData['permitImg']=="" ){
|
Feng.error("营业执照不能为空!");
|
return;
|
}
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/memMerchant/update", function (data) {
|
if (data.code == 200) {
|
Feng.success("修改成功!");
|
window.parent.MemMerchant.table.refresh();
|
MemMerchantInfoDlg.close();
|
} else {
|
Feng.error("修改失败!" + data.message);
|
}
|
}, function (data) {
|
Feng.error("修改失败!");
|
});
|
ajax.set(this.memMerchantInfoData);
|
ajax.start();
|
};
|
|
$(function () {
|
// 初始化图片上传
|
var imageUp = new $WebUploadImage("aptitudeImg");
|
imageUp.setUploadBarId("aptitudeBar");
|
imageUp.init();
|
var permitImg = new $WebUploadImage("permitImg");
|
permitImg.setUploadBarId("permitBar");
|
permitImg.init();
|
// 初始化开始时间、结束时间
|
laydate.render({
|
elem: '#startTime', type: 'datetime'
|
});
|
// 初始化开始时间、结束时间
|
laydate.render({
|
elem: '#workStartTime', type: 'time', format:'HH:mm',
|
});
|
laydate.render({
|
elem: '#workEndTime', type: 'time', format:'HH:mm',
|
});
|
Feng.initValidator( "formId", MemMerchantInfoDlg.validFields);
|
});
|