diff --git a/o2web/source/x_component_process_Xform/$ElModule.js b/o2web/source/x_component_process_Xform/$ElModule.js index 057ec4559b3c7627fd993f762eeb568d2e4a9674..0aa187be32fa7a5db6e2e61c3cd238c33048b718 100644 --- a/o2web/source/x_component_process_Xform/$ElModule.js +++ b/o2web/source/x_component_process_Xform/$ElModule.js @@ -56,7 +56,7 @@ o2.xApplication.process.Xform.$ElModule = MWF.APP$ElModule = new Class( if (arr.length>1 && arr[1]){ var modelId = this.json.id.substring(0, this.json.id.lastIndexOf("..")); modelId = (modelId) ? modelId+".."+arr[1] : arr[1]; - this.json[arr[1]] = this.getBusinessDataById(null, modelId); + this.json[arr[1]] = this._getBusinessData(modelId) || ""; this.vModels.push(arr[1]); } } @@ -121,7 +121,7 @@ o2.xApplication.process.Xform.$ElModule = MWF.APP$ElModule = new Class( app.watch[m] = function(val, oldVal){ var modelId = this.json.id.substring(0, this.json.id.lastIndexOf("..")); modelId = (modelId) ? modelId+".."+m : m; - this.setBusinessDataById(val, modelId); + this._setBusinessData(val, modelId); }.bind(this); }.bind(this)); } diff --git a/o2web/source/x_component_process_Xform/$Module.js b/o2web/source/x_component_process_Xform/$Module.js index a6a626ef26717ab7b357d4a56fb5c42fb9c1f46b..c2f84ee06df23eafc807d916d10febb14af76323 100644 --- a/o2web/source/x_component_process_Xform/$Module.js +++ b/o2web/source/x_component_process_Xform/$Module.js @@ -209,16 +209,16 @@ MWF.xApplication.process.Xform.$Module = MWF.APP$Module = new Class( }.bind(this)); } }, - _getBusinessData: function(){ + _getBusinessData: function(id){ var v; if (this.json.section=="yes"){ - v = this._getBusinessSectionData(); + v = this._getBusinessSectionData(id); }else { if (this.json.type==="Opinion"){ - v = this._getBusinessSectionDataByPerson(); + v = this._getBusinessSectionDataByPerson(id); }else{ // return this.form.businessData.data[this.json.id] || ""; - var value = this.getBusinessDataById(); + var value = this.getBusinessDataById(null, id); return (o2.typeOf(value)!=="null") ? value : ""; //return this.getBusinessDataById() || ""; } @@ -226,63 +226,63 @@ MWF.xApplication.process.Xform.$Module = MWF.APP$Module = new Class( //if (o2.typeOf(v)==="string") v = o2.dtxt(v); return v; }, - _getBusinessSectionData: function(){ + _getBusinessSectionData: function(id){ switch (this.json.sectionBy){ case "person": - return this._getBusinessSectionDataByPerson(); + return this._getBusinessSectionDataByPerson(id); case "unit": - return this._getBusinessSectionDataByUnit(); + return this._getBusinessSectionDataByUnit(id); case "activity": - return this._getBusinessSectionDataByActivity(); + return this._getBusinessSectionDataByActivity(id); case "splitValue": - return this._getBusinessSectionDataBySplitValue(); + return this._getBusinessSectionDataBySplitValue(id); case "script": - return this._getBusinessSectionDataByScript(((this.json.sectionByScript) ? this.json.sectionByScript.code : "")); + return this._getBusinessSectionDataByScript(((this.json.sectionByScript) ? this.json.sectionByScript.code : ""), id); default: // return this.form.businessData.data[this.json.id] || ""; - return this.getBusinessDataById() || ""; + return this.getBusinessDataById(null, id) || ""; } }, - _getBusinessSectionDataByPerson: function(){ - this.form.sectionListObj[this.json.id] = layout.desktop.session.user.id; + _getBusinessSectionDataByPerson: function(id){ + this.form.sectionListObj[id||this.json.id] = layout.desktop.session.user.id; // var dataObj = this.form.businessData.data[this.json.id]; - var dataObj = this.getBusinessDataById(); + var dataObj = this.getBusinessDataById(null, id); return (dataObj) ? (dataObj[layout.desktop.session.user.id] || "") : ""; }, - _getBusinessSectionDataByUnit: function(){ - this.form.sectionListObj[this.json.id] = ""; + _getBusinessSectionDataByUnit: function(id){ + this.form.sectionListObj[id || this.json.id] = ""; // var dataObj = this.form.businessData.data[this.json.id]; - var dataObj = this.getBusinessDataById(); + var dataObj = this.getBusinessDataById(null, id); if (!dataObj) return ""; var key = (this.form.businessData.task) ? this.form.businessData.task.unit : ""; - if (key) this.form.sectionListObj[this.json.id] = key; + if (key) this.form.sectionListObj[id||this.json.id] = key; return (key) ? (dataObj[key] || "") : ""; }, - _getBusinessSectionDataByActivity: function(){ - this.form.sectionListObj[this.json.id] = ""; + _getBusinessSectionDataByActivity: function(id){ + this.form.sectionListObj[id||this.json.id] = ""; // var dataObj = this.form.businessData.data[this.json.id]; - var dataObj = this.getBusinessDataById(); + var dataObj = this.getBusinessDataById(null, id); if (!dataObj) return ""; var key = (this.form.businessData.work) ? this.form.businessData.work.activity : ""; - if (key) this.form.sectionListObj[this.json.id] = key; + if (key) this.form.sectionListObj[id||this.json.id] = key; return (key) ? (dataObj[key] || "") : ""; }, - _getBusinessSectionDataBySplitValue: function(){ - this.form.sectionListObj[this.json.id] = ""; + _getBusinessSectionDataBySplitValue: function(id){ + this.form.sectionListObj[id||this.json.id] = ""; // var dataObj = this.form.businessData.data[this.json.id]; - var dataObj = this.getBusinessDataById(); + var dataObj = this.getBusinessDataById(null, id); if (!dataObj) return ""; var key = (this.form.businessData.work) ? this.form.businessData.work.splitValue : ""; - if (key) this.form.sectionListObj[this.json.id] = key; + if (key) this.form.sectionListObj[id||this.json.id] = key; return (key) ? (dataObj[key] || "") : ""; }, - _getBusinessSectionDataByScript: function(code){ - this.form.sectionListObj[this.json.id] = ""; + _getBusinessSectionDataByScript: function(code, id){ + this.form.sectionListObj[id||this.json.id] = ""; // var dataObj = this.form.businessData.data[this.json.id]; - var dataObj = this.getBusinessDataById(); + var dataObj = this.getBusinessDataById(null, id); if (!dataObj) return ""; var key = this.form.Macro.exec(code, this); - if (key) this.form.sectionListObj[this.json.id] = key; + if (key) this.form.sectionListObj[id||this.json.id] = key; return (key) ? (dataObj[key] || "") : ""; }, _setEnvironmentData: function(v){ @@ -384,67 +384,67 @@ MWF.xApplication.process.Xform.$Module = MWF.APP$Module = new Class( return evdata; }, - _setBusinessData: function(v){ + _setBusinessData: function(v, id){ //if (o2.typeOf(v)==="string") v = o2.txt(v); if (this.json.section=="yes"){ - this._setBusinessSectionData(v); + this._setBusinessSectionData(v, id); }else { if (this.json.type==="Opinion"){ - this._setBusinessSectionDataByPerson(v); + this._setBusinessSectionDataByPerson(v, id); }else{ - this.setBusinessDataById(v); + this.setBusinessDataById(v, id); if (this.json.isTitle) this.form.businessData.$work.title = v; } } }, - _setBusinessSectionData: function(v){ + _setBusinessSectionData: function(v, id){ switch (this.json.sectionBy){ case "person": - this._setBusinessSectionDataByPerson(v); + this._setBusinessSectionDataByPerson(v, id); break; case "unit": - this._setBusinessSectionDataByUnit(v); + this._setBusinessSectionDataByUnit(v, id); break; case "activity": - this._setBusinessSectionDataByActivity(v); + this._setBusinessSectionDataByActivity(v, id); break; case "splitValue": - this._setBusinessSectionDataBySplitValue(v); + this._setBusinessSectionDataBySplitValue(v, id); break; case "script": - this._setBusinessSectionDataByScript(this.json.sectionByScript.code, v); + this._setBusinessSectionDataByScript(this.json.sectionByScript.code, v, id); break; default: - this.setBusinessDataById(v); + this.setBusinessDataById(v, id); } }, - _setBusinessSectionDataByPerson: function(v){ + _setBusinessSectionDataByPerson: function(v, id){ var key = layout.desktop.session.user.id; - this._setBusinessSectionDataByKey(key, v); + this._setBusinessSectionDataByKey(key, v, id); }, - _setBusinessSectionDataByUnit: function(v){ + _setBusinessSectionDataByUnit: function(v, id){ var key = (this.form.businessData.task) ? this.form.businessData.task.unit : ""; - this._setBusinessSectionDataByKey(key, v); + this._setBusinessSectionDataByKey(key, v, id); }, - _setBusinessSectionDataByActivity: function(v){ + _setBusinessSectionDataByActivity: function(v, id){ var key = (this.form.businessData.work) ? this.form.businessData.work.activity : ""; - this._setBusinessSectionDataByKey(key, v); + this._setBusinessSectionDataByKey(key, v, id); }, - _setBusinessSectionDataBySplitValue: function(v){ + _setBusinessSectionDataBySplitValue: function(v, id){ var key = (this.form.businessData.work) ? this.form.businessData.work.splitValue : ""; - this._setBusinessSectionDataByKey(key, v); + this._setBusinessSectionDataByKey(key, v, id); }, - _setBusinessSectionDataByScript: function(code, v){ + _setBusinessSectionDataByScript: function(code, v, id){ var key = this.form.Macro.exec(code, this); - this._setBusinessSectionDataByKey(key, v); + this._setBusinessSectionDataByKey(key, v, id); }, - _setBusinessSectionDataByKey: function(key, v){ + _setBusinessSectionDataByKey: function(key, v, id){ if (key){ - var dataObj = this.getBusinessDataById(); + var dataObj = this.getBusinessDataById(null, id); var evdata; if (!dataObj){ dataObj = {}; - evdata = this.setBusinessDataById(dataObj); + evdata = this.setBusinessDataById(dataObj, id); } dataObj[key] = v; if (evdata) evdata.check(key, v); diff --git a/o2web/source/x_component_process_Xform/Elcommon.js b/o2web/source/x_component_process_Xform/Elcommon.js index 7a8715e0f33923981b7cdc4644f1bf03e2208544..29b44493e829cbd52b9a48d1c89b55bafd872bfa 100644 --- a/o2web/source/x_component_process_Xform/Elcommon.js +++ b/o2web/source/x_component_process_Xform/Elcommon.js @@ -44,8 +44,10 @@ o2.xApplication.process.Xform.Elcommon = o2.APPElcommon = new Class( }, _loadUserInterface: function(){ debugger; + this.field = true; this.node.set("html", this._createElementHtml()); - this._checkVueHtml(); + //this._checkVueHtml(); + this._checkVmodel(); this.node.set({ "id": this.json.id, @@ -95,10 +97,10 @@ o2.xApplication.process.Xform.Elcommon = o2.APPElcommon = new Class( switch (ty){ case "object": Object.keys(app.data).each(function(k){ - if (!this.json.hasOwnProperty(k)) this.json[k] = app.data[k]; + this.json[k] = app.data[k]; //this.form.Macro.environment.data.add(k, app.data[k]); }.bind(this)); - app.data = this.this.json; + app.data = this.json; // app.data = this.json; // app.data = Object.merge(this.json, this.form.Macro.environment.data); break; @@ -111,7 +113,7 @@ o2.xApplication.process.Xform.Elcommon = o2.APPElcommon = new Class( //_self.form.Macro.environment.data.add(_self.json.id, d); Object.keys(d).each(function(k){ - if (!_self.json.hasOwnProperty(k)) _self.json[k] = d[k]; + _self.json[k] = d[k]; //_self.form.Macro.environment.data.add(k, d[k]); }); //var data = Object.merge(_slef.json); @@ -165,24 +167,49 @@ o2.xApplication.process.Xform.Elcommon = o2.APPElcommon = new Class( // return html; // }, _checkVmodel: function(text){ - if (text){ - this.vModels = []; - var reg = /(?:v-model)(?:.lazy|.number|.trim)?(?:\s*=\s*)(?:["'])?([^"']*)/g; - var arr; - while ((arr = reg.exec(text)) !== null) { - if (arr.length>1 && arr[1]){ - var modelId = this.json.id.substring(0, this.json.id.lastIndexOf("..")); - modelId = (modelId) ? modelId+".."+arr[1] : arr[1]; - this.json[arr[1]] = this.getBusinessDataById(null, modelId); - this.vModels.push(arr[1]); + // if (text){ + // this.vModels = []; + // var reg = /(?:v-model)(?:.lazy|.number|.trim)?(?:\s*=\s*)(?:["'])?([^"']*)/g; + // var arr; + // while ((arr = reg.exec(text)) !== null) { + // if (arr.length>1 && arr[1]){ + // var modelId = this.json.id.substring(0, this.json.id.lastIndexOf("..")); + // modelId = (modelId) ? modelId+".."+arr[1] : arr[1]; + // this.json[arr[1]] = this._getBusinessData(modelId); + // this.vModels.push(arr[1]); + // } + // } + // } + var nodes = this.node.querySelectorAll("*[v-model]"); + this.vModels = []; + var arrs = ["el-checkbox-group"]; + nodes.forEach(function(node){ + var model = node.get("v-model"); + var tag = node.tagName.toString().toLowerCase(); + if (model){ + var modelId = this.json.id.substring(0, this.json.id.lastIndexOf("..")); + modelId = (modelId) ? modelId+".."+model : model; + this.json[model] = this._getBusinessData(modelId); + if (!this.json[model]){ + this.json[model] = (arrs.indexOf(tag)===-1) ? "" : [] } + this.vModels.push(model); } - } + }.bind(this)); }, _createElementHtml: function(){ var html = this.json.vueTemplate || ""; - if (html) this._checkVmodel(html); + // if (html) this._checkVmodel(html); // return this._filterHtml(html); return html; - } + }, + resetData: function(){ + if (this.vModels && this.vModels.length){ + this.vModels.forEach(function(m){ + var modelId = this.json.id.substring(0, this.json.id.lastIndexOf("..")); + modelId = (modelId) ? modelId+".."+m : m; + this.json[m] = this._getBusinessData(modelId); + }.bind(this)); + } + }, });