|
|
@@ -0,0 +1,196 @@
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @param {*} modelData 当前绑定的数据模型
|
|
|
+ * @param {*} actions 操作集合
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+export default function(modelData, actions){
|
|
|
+
|
|
|
+ this.modelData = modelData;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取数据记录的Id
|
|
|
+ */
|
|
|
+ this.getRecordId = function(){
|
|
|
+ return this.modelData.id;
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取字段(文本、数字类型)的值
|
|
|
+ * @param {string} fieldName 字段名称
|
|
|
+ */
|
|
|
+ this.getFieldValue = function(fieldName){
|
|
|
+ return this.modelData.data[fieldName];
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置字段(文本、数字类型)的值
|
|
|
+ * @param {string} fieldName 字段名称
|
|
|
+ * @param { com.leanwo.prodog.restful.base.model.FieldValue } fieldValue 字段值
|
|
|
+ */
|
|
|
+ this.setFieldValue = function(fieldName, fieldValue){
|
|
|
+ this.modelData.data[fieldName] = fieldValue;
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取字段(搜索框、下拉框类型)的id
|
|
|
+ * @param {string} fieldName 字段名称
|
|
|
+ */
|
|
|
+ this.getFieldValueId = function(fieldName){
|
|
|
+ return this.modelData.data[fieldName].id;
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置字段(搜索框、下拉框类型)的id
|
|
|
+ * @param {string} fieldName 字段名称
|
|
|
+ * @param {long} id
|
|
|
+ */
|
|
|
+ this.setFieldValueId = function(filedName, id){
|
|
|
+ this.modelData.data[filedName].id = id;
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取显示的值,返回数组
|
|
|
+ * @param {string} fieldName 字段名称
|
|
|
+ */
|
|
|
+ this.getDispalyValue = function(fieldName){
|
|
|
+ return this.modelData.data[fieldName].displayValue;
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置显示的值(数组)
|
|
|
+ * @param {string} fieldName 字段名称
|
|
|
+ * @param {*} displayValue 数组
|
|
|
+ */
|
|
|
+ this.setDispalyValue = function(fieldName, displayValue){
|
|
|
+ this.modelData.data[fieldName].displayValue = displayValue;
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取显示的第一个值
|
|
|
+ * @param {string} fieldName 字段名称
|
|
|
+ */
|
|
|
+ this.getDispalyValue0 = function(fieldName){
|
|
|
+ return this.modelData.data[fieldName].displayValue[0];
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置显示的第一个值
|
|
|
+ * @param {string} fieldName 字段名称
|
|
|
+ * @param {string} displayValue0 显示的值
|
|
|
+ */
|
|
|
+ this.setDispalyValue0 = function(fieldName, displayValue0){
|
|
|
+ this.modelData.data[fieldName].displayValue[0] = displayValue0;
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置自定义的属性
|
|
|
+ * @param {string} propertyName 属性名称
|
|
|
+ * @param {object} propertyValue 属性值
|
|
|
+ */
|
|
|
+ this.setCustomerProperty = function(propertyName, propertyValue){
|
|
|
+ if(this.calloutProperty == null){
|
|
|
+ this.calloutProperty = {};
|
|
|
+ }
|
|
|
+ this.calloutProperty[propertyName] = propertyValue;
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取自定义的属性
|
|
|
+ * @param {string} propertyName 属性名称
|
|
|
+ */
|
|
|
+ this.getCustomerProperty = function(propertyName){
|
|
|
+ if(this.calloutProperty == null){
|
|
|
+ this.calloutProperty = {};
|
|
|
+ }
|
|
|
+ return this.calloutProperty[propertyName];
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取API的地址
|
|
|
+ * @param {string} apiName
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+ this.getApiURL = function(apiName){
|
|
|
+ //获取当前网址,如: http://localhost:8083/myproj/view/my.jsp
|
|
|
+ var curWwwPath = window.document.location.href;
|
|
|
+ //获取主机地址之后的目录,如: myproj/view/my.jsp
|
|
|
+ var pathName = window.document.location.pathname;
|
|
|
+ var pos = curWwwPath.indexOf(pathName);
|
|
|
+ //获取主机地址,如: http://localhost:8083
|
|
|
+ var localhostPath = curWwwPath.substring(0, pos);
|
|
|
+ return localhostPath + '/api/' + apiName;
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * AJAX 请求头添加token
|
|
|
+ * @param {object} request 请求
|
|
|
+ */
|
|
|
+ this.addTokenToRequest = function(request){
|
|
|
+ request.setRequestHeader('token', localStorage.getItem('#token'));
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取子页签的数据
|
|
|
+ * @param {int} tabIndex 子页签的序号
|
|
|
+ */
|
|
|
+ this.getSubTabModelDatas = function(tabIndex){
|
|
|
+ if(actions === undefined || actions === null){
|
|
|
+ console.error('操作集合 actions 为空,不能获取子页签的数据。');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const subTabsRef = actions.subTabsRef;
|
|
|
+ if(subTabsRef === undefined || subTabsRef === null){
|
|
|
+ console.error('操作集合 action.subTabsRef 为空,不能获取子页签的数据。');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ return subTabsRef[tabIndex].modelDatas;
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 子页签增加数据
|
|
|
+ * @param {int} tabIndex 子页签的序号
|
|
|
+ * @param {com.leanwo.prodog.restful.base.model.ModelData} subTabNewModelData 子页签新增的数据
|
|
|
+ */
|
|
|
+ this.addSubTabModelData = function(tabIndex, subTabNewModelData){
|
|
|
+ return this.subTabsRef[tabIndex].addModelData(subTabNewModelData);
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改父页签的数据
|
|
|
+ * @param { String } fieldName 字段名称
|
|
|
+ * @param { com.leanwo.prodog.restful.base.model.FieldValue } fieldValue 字段的值
|
|
|
+ * @author YangZhiJie 20211012
|
|
|
+ */
|
|
|
+ this.changeParentModelData = function(fieldName, fieldValue){
|
|
|
+ if(actions === undefined || actions === null){
|
|
|
+ console.error('操作集合 actions 为空,不能修改父页签的数据。');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const changeParentModelData = actions.changeParentModelData;
|
|
|
+ if(changeParentModelData === undefined || changeParentModelData === null){
|
|
|
+ console.error('操作集合 action.changeParentModelData 为空,不能修改父页签的数据。');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ changeParentModelData(fieldName, fieldValue);
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取本页签的表格数据
|
|
|
+ */
|
|
|
+ this.getModelDatas = function(){
|
|
|
+ if(actions === undefined || actions === null){
|
|
|
+ console.error('操作集合 actions 为空,不能获取本页签的表格数据。');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ return actions.modelDatas;
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ return this;
|
|
|
+};
|