@wufengteam/wform
Version:
@wufengteam/wform
438 lines • 16.9 kB
JavaScript
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
/* eslint-disable no-console */
import security from '@lingxiteam/security';
import { isString, isPlainObject } from './utils/tool';
import Config from './config';
import Address from './Address';
import Attachments from './Attachments';
import Autograph from './Autograph';
import CheckUpload from './CheckUpload';
import MemberPicker from './MemberPicker';
import Location from './Location';
import DataLinkagePc from './DataLinkage/DataLinkagePc';
import DataLinkageH5 from './DataLinkage/DataLinkageH5';
import DataQueryPC from './DataQuery/DataQueryPC';
import DataQueryH5 from './DataQuery/DataQueryH5';
import TextRecognition from './TextRecognition';
import Api from './Api';
import SubFormPc from './SubForm/SubFormPc';
import SubFormH5 from './SubForm/SubFormH5';
import DformCascader from './DformCascader';
import TreeSelect from './TreeSelect';
import ImageShowEdH5 from './ImageShow/ImageShowEdH5';
import ImageShowEdPc from './ImageShow/ImageShowEdPc';
import ImageShowH5 from './ImageShow/ImageShowH5';
import ImageShowPc from './ImageShow/ImageShowPc';
import AddMemberPc from './AddMember/AddMemberPc';
import AddMemberH5 from './AddMember/AddMemberH5';
import AddDepartmentPC from './AddDepartment/AddDepartmentPC';
import AddDepartmentH5 from './AddDepartment/AddDepartmentH5';
import SerialNumberH5 from './SerialNumber/SerialNumberH5';
import SerialNumberPc from './SerialNumber/SerialNumberPc';
import Empty from './components/Empty';
import WFTabsPc from './WFTabs/WFTabsPc';
import WFViewPc from './WFView/WFViewPc';
export { Address, Attachments, Autograph, CheckUpload, MemberPicker, Location, DataLinkagePc, DataLinkageH5, DataQueryPC, DataQueryH5, TextRecognition, Api, SubFormPc, SubFormH5, DformCascader, TreeSelect, ImageShowEdH5, ImageShowEdPc, ImageShowH5, ImageShowPc, AddMemberPc, AddMemberH5, AddDepartmentPC, SerialNumberH5, SerialNumberPc, Empty, WFTabsPc, WFViewPc };
export { default as subFormValidateData } from './utils/subFormValidateData';
export { default as subFormDefaultValue } from './utils/subFormDefaultValue';
export { default as subFormStatistics } from './utils/subFormStatistics';
export { default as getBusinessRulesFn } from './utils/getBusinessRulesFn';
export { default as DataLinkageEdPc } from './DataLinkage/DataLinkageEdPc';
export { default as DataLinkageEdH5 } from './DataLinkage/DataLinkageEdH5';
export { default as DataQueryEDPC } from './DataQuery/DataQueryEDPC';
export { default as DataQueryEDH5 } from './DataQuery/DataQueryEDH5';
export { default as MobileAddMemberModal } from './MemberPicker/components/MobileAddMemberModal';
export { default as AddMemberModal } from './MemberPicker/AddMemberModal';
export { default as UnCustomizeMember } from './MemberPicker/UnCustomizeMember';
export { default as AddDepartModal } from './MemberPicker/AddDepartModal';
export { default as SubFormEdPc } from './SubForm/SubFormEdPc';
export { default as SerialNumberEdPc } from './SerialNumber/SerialNumberEdPc';
export { default as SerialNumberEdH5 } from './SerialNumber/SerialNumberEdH5';
export var getWformPcFactoryRegistry = function getWformPcFactoryRegistry() {
return [{
component: AddMemberPc,
config: Config.AddMember
}, {
component: AddDepartmentPC,
config: Config.AddDepartment
}, {
component: CheckUpload,
config: Config.CheckUpload
}, {
component: Address,
config: Config.Address
}, {
component: Autograph,
config: Config.Autograph
}, {
component: Attachments,
config: Config.Attachments
}, {
component: Location,
config: Config.Location
}, {
component: DataLinkagePc,
config: Config.DataLinkage
}, {
component: DataQueryPC,
config: Config.DataQuery
}, {
component: TextRecognition,
config: Config.TextRecognition
}, {
component: Api,
config: Config.Api
}, {
component: SubFormPc,
config: Config.SubForm
}, {
component: ImageShowPc,
config: Config.ImageShow
}, {
component: SerialNumberPc,
config: Config.SerialNumber
}, {
component: Empty,
config: Config.BOFramerH5
}, {
component: WFTabsPc,
config: Config.WFTabs
}, {
component: WFViewPc,
config: Config.WFTabPane
}, {
component: WFViewPc,
config: Config.WFView
}];
};
export var getWformH5FactoryRegistry = function getWformH5FactoryRegistry() {
return [{
component: AddMemberH5,
config: Object.assign(Object.assign({}, Config.AddMember), {
platform: 'h5'
})
}, {
component: AddDepartmentH5,
config: Object.assign(Object.assign({}, Config.AddDepartment), {
platform: 'h5'
})
}, {
component: CheckUpload,
config: Object.assign(Object.assign({}, Config.CheckUpload), {
platform: 'h5'
})
}, {
component: Address,
config: Object.assign(Object.assign({}, Config.Address), {
platform: 'h5'
})
}, {
component: Autograph,
config: Object.assign(Object.assign({}, Config.Autograph), {
platform: 'h5'
})
}, {
component: Attachments,
config: Object.assign(Object.assign({}, Config.Attachments), {
platform: 'h5'
})
}, {
component: Location,
config: Object.assign(Object.assign({}, Config.Location), {
platform: 'h5'
})
}, {
component: DataLinkageH5,
config: Object.assign(Object.assign({}, Config.DataLinkage), {
platform: 'h5'
})
}, {
component: DataQueryH5,
config: Object.assign(Object.assign({}, Config.DataQuery), {
platform: 'h5'
})
}, {
component: DformCascader,
config: Config.DformCascader
}, {
component: TreeSelect,
config: Config.TreeSelect
}, {
component: TextRecognition,
config: Object.assign(Object.assign({}, Config.TextRecognition), {
platform: 'h5'
})
}, {
component: Api,
config: Object.assign(Object.assign({}, Config.Api), {
platform: 'h5'
})
}, {
component: SubFormH5,
config: Object.assign(Object.assign({}, Config.SubForm), {
platform: 'h5'
})
}, {
component: ImageShowH5,
config: Object.assign(Object.assign({}, Config.ImageShow), {
platform: 'h5'
})
}, {
component: SerialNumberH5,
config: Object.assign(Object.assign({}, Config.SerialNumber), {
platform: 'h5'
})
}, {
component: Empty,
config: Object.assign(Object.assign({}, Config.BOFramerPc), {
platform: 'h5'
})
}];
};
/**
* 是否包含某属性,或的关系。 包含`propertyNames`中的一个值即可
* @param target
* @param propertyNames
*/
export var hasSomeOwnProperty = function hasSomeOwnProperty(target, propertyNames) {
return propertyNames.some(function (property) {
return target.hasOwnProperty(property);
});
};
/**
* 运行态预处理
*/
export var wformPCRunProcess = {
'*': function _(_instance, originProps) {
var basicStatus = originProps.basicStatus;
if (basicStatus) {
var visibleProp;
var disabledProp;
var readOnlyProp;
switch (+basicStatus) {
case 2:
disabledProp = false;
visibleProp = false;
readOnlyProp = false;
break;
case 3:
disabledProp = true;
visibleProp = true;
readOnlyProp = false;
break;
case 1:
default:
disabledProp = false;
visibleProp = true;
readOnlyProp = false;
break;
}
originProps.disabled = disabledProp;
originProps.visible = visibleProp;
originProps.readOnly = readOnlyProp;
}
return originProps;
},
Text: function Text(_instance, originProps) {
var showHtml = originProps.showHtml,
content = originProps.content,
$$componentItem = originProps.$$componentItem;
var appId = $$componentItem.appId,
pageId = $$componentItem.pageId;
var newContent = content;
if (showHtml) {
var imgList = content.match(/<img(?:(?!\/>).|\n)*?\/?>/g);
if (Array.isArray(imgList)) {
imgList.forEach(function (item) {
var _a;
var escapedString = item.replace(/[.*+?^${}()|[\]\\<>\\/]/g, '\\$&');
var reg = new RegExp("".concat(escapedString), 'g');
var fileCodes = (_a = item === null || item === void 0 ? void 0 : item.match(/data-href=".+?"/g)) === null || _a === void 0 ? void 0 : _a[0].match(/".+?"/g);
var _ref = fileCodes || [],
_ref2 = _slicedToArray(_ref, 1),
fileCode = _ref2[0];
fileCode = fileCode === null || fileCode === void 0 ? void 0 : fileCode.substring(1, fileCode.length - 1);
var srcUrl = security.autoSecurityWithUrl("../server/app/file/appFileResource/downloadFileByFileCode?fileCode=".concat(fileCode, "&appId=").concat(appId, "&X-B-TARGET-ID=").concat(pageId, "&X-B-AUTH=1"));
var imgReplaceContent = item.replace(/src\s*=\s*(["'])((?:[^\1"]|\\\1|.)*?)\1/, "src=\"".concat(srcUrl, "\""));
newContent = content.replace(reg, imgReplaceContent);
});
}
originProps.content = newContent;
}
return originProps;
},
MultipleSelect: function MultipleSelect(_instance, originProps) {
if (originProps.value && isString(originProps.value)) {
var val = originProps.value.split(',');
originProps.defaultValue = val;
originProps.value = val;
}
return originProps;
},
'DatePicker|TimePicker': function DatePickerTimePicker(_instance, originProps) {
var _a;
var newDefaultValue = '';
var _originProps$value = originProps.value,
value = _originProps$value === void 0 ? {} : _originProps$value;
if (isPlainObject(value)) {
var type = value.type,
defaultValue = value.defaultValue;
if (type === 'isCurrent') {
newDefaultValue = new Date();
} else if (type === 'now') {
newDefaultValue = defaultValue;
} else if (type === 'custom') {
newDefaultValue = (_a = originProps === null || originProps === void 0 ? void 0 : originProps.defaultValue) === null || _a === void 0 ? void 0 : _a.defaultValue;
}
}
originProps.defaultValue = newDefaultValue;
originProps.value = newDefaultValue;
return originProps;
},
Cascader: function Cascader(_instance, originProps) {
var value = originProps.value;
if (value && isString(value)) {
var newValue = value.split(',');
originProps.value = newValue;
}
return originProps;
},
QuillEditor: function QuillEditor(_instance, originProps) {
originProps.imageType = 'file';
return originProps;
},
BOFramerH5: function BOFramerH5(_instance, originProps) {
originProps.visible = false;
return originProps;
},
'ImgUpload|VideoUpload|StdUpload': function ImgUploadVideoUploadStdUpload(_instance, originProps) {
if (typeof originProps.singleFileMaxSize === 'number') {
originProps.singleFileMaxSize += 'MB';
}
if (typeof originProps.singleFileMinSize === 'number') {
originProps.singleFileMinSize += 'MB';
}
return originProps;
}
};
export var wformH5RunProcess = {
'*': function _(_instance, originProps) {
var basicStatus = originProps.basicStatus;
if (basicStatus) {
var visibleProp;
var disabledProp;
var readOnlyProp;
switch (+basicStatus) {
case 2:
disabledProp = false;
visibleProp = false;
readOnlyProp = false;
break;
case 3:
disabledProp = true;
visibleProp = true;
readOnlyProp = false;
break;
case 4:
disabledProp = false;
visibleProp = true;
readOnlyProp = true;
break;
case 1:
default:
disabledProp = false;
visibleProp = true;
readOnlyProp = false;
break;
}
originProps.disabled = disabledProp;
originProps.visible = visibleProp;
originProps.readOnly = readOnlyProp;
}
return originProps;
},
Text: function Text(_instance, originProps) {
var showHtml = originProps.showHtml,
content = originProps.content,
$$componentItem = originProps.$$componentItem;
var appId = $$componentItem.appId,
pageId = $$componentItem.pageId;
var newContent = content;
if (showHtml) {
var imgList = content.match(/<img(?:(?!\/>).|\n)*?\/?>/g);
if (Array.isArray(imgList)) {
imgList.forEach(function (item) {
var _a;
var escapedString = item.replace(/[.*+?^${}()|[\]\\<>\\/]/g, '\\$&');
var reg = new RegExp("".concat(escapedString), 'g');
var fileCodes = (_a = item === null || item === void 0 ? void 0 : item.match(/data-href=".+?"/g)) === null || _a === void 0 ? void 0 : _a[0].match(/".+?"/g);
var _ref3 = fileCodes || [],
_ref4 = _slicedToArray(_ref3, 1),
fileCode = _ref4[0];
fileCode = fileCode === null || fileCode === void 0 ? void 0 : fileCode.substring(1, fileCode.length - 1);
var srcUrl = security.autoSecurityWithUrl("../server/app/file/appFileResource/downloadFileByFileCode?fileCode=".concat(fileCode, "&appId=").concat(appId, "&X-B-TARGET-ID=").concat(pageId, "&X-B-AUTH=1"));
var imgReplaceContent = item.replace(/src\s*=\s*(["'])((?:[^\1"]|\\\1|.)*?)\1/, "src=\"".concat(srcUrl, "\""));
newContent = content.replace(reg, imgReplaceContent);
});
}
originProps.content = newContent;
}
originProps.style = Object.assign(Object.assign({}, originProps.style), {
padding: '12px 12px 12px 12px',
display: 'inline-block',
width: '100%'
});
return originProps;
},
DformDate: function DformDate(_instance, originProps) {
var _a, _b;
var newDefaultValue = '';
var _originProps$value2 = originProps.value,
value = _originProps$value2 === void 0 ? {} : _originProps$value2;
if (isPlainObject(value)) {
var type = value.type,
defaultValue = value.defaultValue;
if (type === 'isCurrent') {
newDefaultValue = new Date().toUTCString();
} else if (type === 'now') {
newDefaultValue = defaultValue;
} else if (type === 'custom') {
newDefaultValue = (_b = (_a = originProps === null || originProps === void 0 ? void 0 : originProps.defaultValue) === null || _a === void 0 ? void 0 : _a.defaultValue) === null || _b === void 0 ? void 0 : _b.defaultValue;
}
}
originProps.defaultValue = newDefaultValue;
originProps.value = newDefaultValue;
return originProps;
},
DMultiplePicker: function DMultiplePicker(_instance, originProps) {
var value = originProps.value;
if (value && isString(value)) {
var val = value.split(',');
originProps.value = val;
}
return originProps;
},
DformCascader: function DformCascader(_instance, originProps) {
var value = originProps.value;
if (value && isString(value)) {
var newValue = value.split(',');
originProps.value = newValue;
}
return originProps;
},
DformImagePicker: function DformImagePicker(_instance, originProps) {
delete originProps.deleteIcon;
delete originProps.downloadIcon;
delete originProps.previewIcon;
return originProps;
},
null: function _null(_instance, originProps) {
originProps.visible = false;
return originProps;
}
};