/// ec.ask = { isCode: null, api: new ec.api("inquiry"), init: function (isCode, userData) { ke.ui.render(); this.isCode = isCode; this.renderCountry(userData); }, renderCountry: function (userData) { if (this.isCode.country) { Country.bindStore(new ke.table().load(ec.utilities.getCountry(), true)); if (this.isCode.province) { Country.change(function () { var country = Country.get(); Province.bindStore(new ke.table().load(ec.utilities.getProvince(country), true)); Province.setTriggerChange("") Province.find(".box").removeClass("illegal"); if (ec.ask.isCode.city) { City.setTriggerChange(""); City.find(".box").removeClass("illegal"); } }); } if (this.isCode.city) { Province.change(function () { var country = Country.get(); var province = Province.get(); City.bindStore(new ke.table().load(ec.utilities.getCity(country, province), true)); City.setTriggerChange(""); City.find(".box").removeClass("illegal"); }); } Country.setTriggerChange(userData.Country ? userData.Country : (L.isEn ? "China" : "中国")); if (this.isCode.province && userData.Province != null) Province.setTriggerChange(userData.Province); if (this.isCode.city && userData.City != null) City.setTriggerChange(userData.City); } }, confirm: function (hasBack) { var url = ""; if (hasBack == "True") url = document.referrer; else url = L.route + "/category"; var info = ke.createObject(); if (this.isCode.separateFillName) info.Contact = info.Contact1 + info.Contact2; if (this.isCode.address2) info.Address = info.Address1 + "\n" + info.Address2; else info.Address = info.Address1; info.Details = []; var details = {}; details.ProName = info.ProName; details.CASNum = info.CASNum; details.Weight = info.Weight; info.Details.push(details); var msg = this.validate(info); if (!msg) { ec.utilities.loading(); this.api.post("insert", info, function (r) { if (r) { ec.utilities.unLoading(); window.location.href = L.route + "/success?from=" + escape(url); } }); } else { window.top.ec.notify(msg, "question", 3000); } }, giveUp: function (hasBack) { var callbck = function () { if (hasBack == "True") history.back(-1); else window.location.href = L.route + "/category"; }; ec.confirm("" + L.G("您确定放弃询价吗?"), L.G("表单信息将不保存"), callbck); }, validate: function () { var msg = ""; var items = ke.ui.findControls("#inputContent", "input"); items.forEach(function (d) { if (!d.validate() && d.skin.id != "Remark" && msg == "") { msg = d.skin.title.replace("*", "") + L.G(" 是必填项"); } }); return msg; }, } $(window.document).ready(function () { $(window.document).ready(function () { _api_error = ec.api.error; ec.api.error = function (req, textStatus) { ec.utilities.unLoading(false); _api_error(req, textStatus); } }); });