diff --git a/public/components/property/addMeterWater/addMeterWater.html b/public/components/property/addMeterWater/addMeterWater.html index 3c80a7aeb..17c62b98c 100755 --- a/public/components/property/addMeterWater/addMeterWater.html +++ b/public/components/property/addMeterWater/addMeterWater.html @@ -67,7 +67,7 @@
+ class="form-control " >
@@ -80,7 +80,7 @@
-
diff --git a/public/form.html b/public/form.html new file mode 100644 index 000000000..4d6c9ebfb --- /dev/null +++ b/public/form.html @@ -0,0 +1,67 @@ + + + + + + + HC小区管理系统|java110 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ +
+
+ +
+ +
+ +
+ + + +
+
+ + + + + + + + \ No newline at end of file diff --git a/public/formjs/js/form-viewer.umd.js b/public/formjs/js/form-viewer.umd.js new file mode 100644 index 000000000..500af1421 --- /dev/null +++ b/public/formjs/js/form-viewer.umd.js @@ -0,0 +1,2775 @@ +/** + * HC小区管理系统作者 吴学文(mail:928255095@qq.com) 对原有的https://bpmn.io 的 formjs 框架做了 相应修改 主要修改如下: + * 加入 多行文本框,时间组件,日期组件,部分汉化功能 + * + * HC小区管理系统官方尊重作者的贡献未去除bpmn 版权信息,如果您想去除请先联系 bpmn作者,经作者同意后,可以在1758行去除bpmn版权, + * 在未经作者允许的情况下去除bpmn版权造成的侵权问题,HC小区管理系统将不会承担任何责任,由去除版权的公司或者个人承担相应的责任! + * + * 版权归 https://bpmn.io/ 所有,非常感谢bpmn.io 提供这么优秀的框架 + */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.FormViewer = {})); + }(this, (function (exports) { 'use strict'; + + /** + * Flatten array, one level deep. + * + * @param {Array} arr + * + * @return {Array} + */ + + var nativeToString = Object.prototype.toString; + var nativeHasOwnProperty = Object.prototype.hasOwnProperty; + function isUndefined(obj) { + return obj === undefined; + } + function isDefined(obj) { + return obj !== undefined; + } + function isNil(obj) { + return obj == null; + } + function isArray(obj) { + return nativeToString.call(obj) === '[object Array]'; + } + function isNumber(obj) { + return nativeToString.call(obj) === '[object Number]'; + } + function isFunction(obj) { + var tag = nativeToString.call(obj); + return tag === '[object Function]' || tag === '[object AsyncFunction]' || tag === '[object GeneratorFunction]' || tag === '[object AsyncGeneratorFunction]' || tag === '[object Proxy]'; + } + function isString(obj) { + return nativeToString.call(obj) === '[object String]'; + } + /** + * Return true, if target owns a property with the given key. + * + * @param {Object} target + * @param {String} key + * + * @return {Boolean} + */ + + function has(target, key) { + return nativeHasOwnProperty.call(target, key); + } + /** + * Iterate over collection; returning something + * (non-undefined) will stop iteration. + * + * @param {Array|Object} collection + * @param {Function} iterator + * + * @return {Object} return result that stopped the iteration + */ + + function forEach(collection, iterator) { + var val, result; + + if (isUndefined(collection)) { + return; + } + + var convertKey = isArray(collection) ? toNum : identity; + + for (var key in collection) { + if (has(collection, key)) { + val = collection[key]; + result = iterator(val, convertKey(key)); + + if (result === false) { + return val; + } + } + } + } + + function identity(arg) { + return arg; + } + + function toNum(arg) { + return Number(arg); + } + /** + * Bind function against target . + * + * @param {Function} fn + * @param {Object} target + * + * @return {Function} bound function + */ + + function bind(fn, target) { + return fn.bind(target); + } + + function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); + } + + /** + * Convenience wrapper for `Object.assign`. + * + * @param {Object} target + * @param {...Object} others + * + * @return {Object} the target + */ + + function assign(target) { + for (var _len = arguments.length, others = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + others[_key - 1] = arguments[_key]; + } + + return _extends.apply(void 0, [target].concat(others)); + } + /** + * Sets a nested property of a given object to the specified value. + * + * This mutates the object and returns it. + * + * @param {Object} target The target of the set operation. + * @param {(string|number)[]} path The path to the nested value. + * @param {any} value The value to set. + */ + + function set(target, path, value) { + var currentTarget = target; + forEach(path, function (key, idx) { + if (key === '__proto__') { + throw new Error('illegal key: __proto__'); + } + + var nextKey = path[idx + 1]; + var nextTarget = currentTarget[key]; + + if (isDefined(nextKey) && isNil(nextTarget)) { + nextTarget = currentTarget[key] = isNaN(+nextKey) ? {} : []; + } + + if (isUndefined(nextKey)) { + if (isUndefined(value)) { + delete currentTarget[key]; + } else { + currentTarget[key] = value; + } + } else { + currentTarget = nextTarget; + } + }); + return target; + } + /** + * Gets a nested property of a given object. + * + * @param {Object} target The target of the get operation. + * @param {(string|number)[]} path The path to the nested value. + * @param {any} [defaultValue] The value to return if no value exists. + */ + + function get(target, path, defaultValue) { + var currentTarget = target; + forEach(path, function (key) { + // accessing nil property yields + if (isNil(currentTarget)) { + currentTarget = undefined; + return false; + } + + currentTarget = currentTarget[key]; + }); + return isUndefined(currentTarget) ? defaultValue : currentTarget; + } + + var e={"":["",""],_:["",""],"*":["",""],"~":["",""],"\n":["
"]," ":["
"],"-":["
"]};function n(e){return e.replace(RegExp("^"+(e.match(/^(\t| )+/)||"")[0],"gm"),"")}function r(e){return (e+"").replace(/"/g,""").replace(//g,">")}function t(a,c){var o,l,g,s,p,u=/((?:^|\n+)(?:\n---+|\* \*(?: \*)+)\n)|(?:^``` *(\w*)\n([\s\S]*?)\n```$)|((?:(?:^|\n+)(?:\t| {2,}).+)+\n*)|((?:(?:^|\n)([>*+-]|\d+\.)\s+.*)+)|(?:!\[([^\]]*?)\]\(([^)]+?)\))|(\[)|(\](?:\(([^)]+?)\))?)|(?:(?:^|\n+)([^\s].*)\n(-{3,}|={3,})(?:\n+|$))|(?:(?:^|\n+)(#{1,6})\s*(.+)(?:\n+|$))|(?:`([^`].*?)`)|( \n\n*|\n{2,}|__|\*\*|[_*]|~~)/gm,m=[],h="",i=c||{},d=0;function f(n){var r=e[n[1]||""],t=m[m.length-1]==n;return r?r[1]?(t?m.pop():m.push(n),r[0|t]):r[0]:n}function $(){for(var e="";m.length;)e+=f(m[m.length-1]);return e}for(a=a.replace(/^\[(.+?)\]:\s*(.+)$/gm,function(e,n,r){return i[n.toLowerCase()]=r,""}).replace(/^\n+|\n+$/g,"");g=u.exec(a);)l=a.substring(d,g.index),d=u.lastIndex,o=g[0],l.match(/[^\\](\\\\)*\\$/)||((p=g[3]||g[4])?o='
"+n(r(p).replace(/^\n+|\n+$/g,""))+"
":(p=g[6])?(p.match(/\./)&&(g[5]=g[5].replace(/^\d+/gm,"")),s=t(n(g[5].replace(/^\s*[>*+.-]/gm,""))),">"==p?p="blockquote":(p=p.match(/\./)?"ol":"ul",s=s.replace(/^(.*)(\n|$)/gm,"
  • $1
  • ")),o="<"+p+">"+s+""):g[8]?o=''+r(g[7])+'':g[10]?(h=h.replace("",''),o=$()+""):g[9]?o="":g[12]||g[14]?o="<"+(p="h"+(g[14]?g[14].length:g[13]>"="?1:2))+">"+t(g[12]||g[15],i)+"":g[16]?o=""+r(g[16])+"":(g[17]||g[1])&&(o=f(g[17]||"--"))),h+=l,h+=o;return (h+a.substring(d)+$()).replace(/^\n+|\n+$/g,"")} + + var n$1,u,i,t$1,r$1,o={},f=[],e$1=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function c(n,l){for(var u in l)n[u]=l[u];return n}function s(n){var l=n.parentNode;l&&l.removeChild(n);}function a(n,l,u){var i,t,r,o=arguments,f={};for(r in l)"key"==r?i=l[r]:"ref"==r?t=l[r]:f[r]=l[r];if(arguments.length>3)for(u=[u],r=3;r0?v(k.type,k.props,k.key,null,k.__v):k)){if(k.__=u,k.__b=u.__b+1,null===(_=A[h])||_&&k.key==_.key&&k.type===_.type)A[h]=void 0;else for(p=0;p=i.__.length&&i.__.push({}),i.__[t]}function l(n){return o$2=1,p$1(w$1,n)}function p$1(n,r,o){var i=m$1(t$2++,2);return i.t=n,i.__c||(i.__=[o?o(r):w$1(void 0,r),function(n){var t=i.t(i.__[0],n);i.__[0]!==t&&(i.__=[t,i.__[1]],i.__c.setState({}));}],i.__c=u$1),i.__}function d$1(n,u){var r=m$1(t$2++,7);return k$1(r.__H,u)&&(r.__=n(),r.__H=u,r.__h=n),r.__}function A$1(n,t){return o$2=8,d$1(function(){return n},t)}function F(n){var r=u$1.context[n.__c],o=m$1(t$2++,9);return o.__c=n,r?(null==o.__&&(o.__=!0,r.sub(u$1)),r.props.value):n.__}function x$1(){i$1.forEach(function(t){if(t.__P)try{t.__H.__h.forEach(g$1),t.__H.__h.forEach(j$1),t.__H.__h=[];}catch(u){t.__H.__h=[],n$1.__e(u,t.__v);}}),i$1=[];}n$1.__b=function(n){u$1=null,c$1&&c$1(n);},n$1.__r=function(n){f$1&&f$1(n),t$2=0;var r=(u$1=n.__c).__H;r&&(r.__h.forEach(g$1),r.__h.forEach(j$1),r.__h=[]);},n$1.diffed=function(t){e$2&&e$2(t);var o=t.__c;o&&o.__H&&o.__H.__h.length&&(1!==i$1.push(o)&&r$2===n$1.requestAnimationFrame||((r$2=n$1.requestAnimationFrame)||function(n){var t,u=function(){clearTimeout(r),b$1&&cancelAnimationFrame(t),setTimeout(n);},r=setTimeout(u,100);b$1&&(t=requestAnimationFrame(u));})(x$1)),u$1=void 0;},n$1.__c=function(t,u){u.some(function(t){try{t.__h.forEach(g$1),t.__h=t.__h.filter(function(n){return !n.__||j$1(n)});}catch(r){u.some(function(n){n.__h&&(n.__h=[]);}),u=[],n$1.__e(r,t.__v);}}),a$1&&a$1(t,u);},n$1.unmount=function(t){v$1&&v$1(t);var u=t.__c;if(u&&u.__H)try{u.__H.__.forEach(g$1);}catch(t){n$1.__e(t,u.__v);}};var b$1="function"==typeof requestAnimationFrame;function g$1(n){var t=u$1;"function"==typeof n.__c&&n.__c(),u$1=t;}function j$1(n){var t=u$1;n.__c=n.__(),u$1=t;}function k$1(n,t){return !n||n.length!==t.length||t.some(function(t,u){return t!==n[u]})}function w$1(n,t){return "function"==typeof t?t(n):t} + + var e$3,o$3={};function n$2(r,t,e){if(3===r.nodeType){var o="textContent"in r?r.textContent:r.nodeValue||"";if(!1!==n$2.options.trim){var a=0===t||t===e.length-1;if((!(o=o.match(/^[\s\n]+$/g)&&"all"!==n$2.options.trim?" ":o.replace(/(^[\s\n]+|[\s\n]+$)/g,"all"===n$2.options.trim||a?"":" "))||" "===o)&&e.length>1&&a)return null}return o}if(1!==r.nodeType)return null;var p=String(r.nodeName).toLowerCase();if("script"===p&&!n$2.options.allowScripts)return null;var l,s,u=n$2.h(p,function(r){var t=r&&r.length;if(!t)return null;for(var e={},o=0;o\n"+r+""):(i="xml",a='\n'+r+"");try{o=(new DOMParser).parseFromString(a,p);}catch(r){n=r;}if(o||"html"!==t||((o=e$3||(e$3=function(){if(document.implementation&&document.implementation.createHTMLDocument)return document.implementation.createHTMLDocument("");var r=document.createElement("iframe");return r.style.cssText="position:absolute; left:0; top:-999em; width:1px; height:1px; overflow:hidden;",r.setAttribute("sandbox","allow-forms"),document.body.appendChild(r),r.contentWindow.document}())).open(),o.write(a),o.close()),o){var l=o.getElementsByTagName(i)[0],s=l.firstChild;return r&&!s&&(l.error="Document parse failed."),s&&"parsererror"===String(s.nodeName).toLowerCase()&&(s.removeChild(s.firstChild),s.removeChild(s.lastChild),l.error=s.textContent||s.nodeValue||n||"Unknown error",l.removeChild(s)),l}}(r,t);if(u&&u.error)throw new Error(u.error);var c=u&&u.body||u;l$1.map=i||p$2;var m=c&&function(r,t,e,a){return n$2.visitor=t,n$2.h=e,n$2.options=a||o$3,n$2(r)}(c,l$1,a,s);return l$1.map=null,m&&m.props&&m.props.children||null}(c,u,C,this.map,g);}catch(r){f?f({error:r}):"undefined"!=typeof console&&console.error&&console.error("preact-markup: "+r);}if(!1===i)return s||null;var x=w.hasOwnProperty("className")?"className":"class",b=w[x];return b?b.splice?b.splice(0,0,"markup"):"string"==typeof b?w[x]+=" markup":"object"==typeof b&&(b.markup=!0):w[x]="markup",C("div",w,s||null)},i}(p)); + + function C$1(n,t){for(var e in t)n[e]=t[e];return n}function S(n,t){for(var e in n)if("__source"!==e&&!(e in t))return !0;for(var r in t)if("__source"!==r&&n[r]!==t[r])return !0;return !1}function E(n){this.props=n;}(E.prototype=new p).isPureReactComponent=!0,E.prototype.shouldComponentUpdate=function(n,t){return S(this.props,n)||S(this.state,t)};var w$2=n$1.__b;n$1.__b=function(n){n.type&&n.type.__f&&n.ref&&(n.props.ref=n.ref,n.ref=null),w$2&&w$2(n);};var A$2=n$1.__e;function O(){this.__u=0,this.t=null,this.__b=null;}function L$1(n){var t=n.__.__c;return t&&t.__e&&t.__e(n)}function D(){this.u=null,this.o=null;}n$1.__e=function(n,t,e){if(n.then)for(var r,u=t;u=u.__;)if((r=u.__c)&&r.__c)return null==t.__e&&(t.__e=e.__e,t.__k=e.__k),r.__c(n,t);A$2(n,t,e);},(O.prototype=new p).__c=function(n,t){var e=t.__c,r=this;null==r.t&&(r.t=[]),r.t.push(e);var u=L$1(r.__v),o=!1,i=function(){o||(o=!0,e.componentWillUnmount=e.__c,u?u(l):l());};e.__c=e.componentWillUnmount,e.componentWillUnmount=function(){i(),e.__c&&e.__c();};var l=function(){if(!--r.__u){if(r.state.__e){var n=r.state.__e;r.__v.__k[0]=function n(t,e,r){return t&&(t.__v=null,t.__k=t.__k&&t.__k.map(function(t){return n(t,e,r)}),t.__c&&t.__c.__P===e&&(t.__e&&r.insertBefore(t.__e,t.__d),t.__c.__e=!0,t.__c.__P=r)),t}(n,n.__c.__P,n.__c.__O);}var t;for(r.setState({__e:r.__b=null});t=r.t.pop();)t.forceUpdate();}},f=!0===t.__h;r.__u++||f||r.setState({__e:r.__b=r.__v.__k[0]}),n.then(i,i);},O.prototype.componentWillUnmount=function(){this.t=[];},O.prototype.render=function(n,t){if(this.__b){if(this.__v.__k){var e=document.createElement("div"),r=this.__v.__k[0].__c;this.__v.__k[0]=function n(t,e,r){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach(function(n){"function"==typeof n.__c&&n.__c();}),t.__c.__H=null),null!=(t=C$1({},t)).__c&&(t.__c.__P===r&&(t.__c.__P=e),t.__c=null),t.__k=t.__k&&t.__k.map(function(t){return n(t,e,r)})),t}(this.__b,e,r.__O=r.__P);}this.__b=null;}var u=t.__e&&a(y,null,n.fallback);return u&&(u.__h=null),[a(y,null,t.__e?null:n.children),u]};var F$1=function(n,t,e){if(++e[1]===e[0]&&n.o.delete(t),n.props.revealOrder&&("t"!==n.props.revealOrder[0]||!n.o.size))for(e=n.u;e;){for(;e.length>3;)e.pop()();if(e[1]>>1,1),t.i.removeChild(n);}}),N(a(M$1,{context:t.context},n.__v),t.l)):t.l&&t.componentWillUnmount();}function j$2(n,t){return a(T$1,{__v:n,i:t})}(D.prototype=new p).__e=function(n){var t=this,e=L$1(t.__v),r=t.o.get(n);return r[0]++,function(u){var o=function(){t.props.revealOrder?(r.push(u),F$1(t,n,r)):u();};e?e(o):o();}},D.prototype.render=function(n){this.u=null,this.o=new Map;var t=w(n.children);n.revealOrder&&"b"===n.revealOrder[0]&&t.reverse();for(var e=t.length;e--;)this.o.set(t[e],this.u=[1,0,this.u]);return n.children},D.prototype.componentDidUpdate=D.prototype.componentDidMount=function(){var n=this;this.o.forEach(function(t,e){F$1(n,e,t);});};var I$1="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,W=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|fill|flood|font|glyph(?!R)|horiz|marker(?!H|W|U)|overline|paint|stop|strikethrough|stroke|text(?!L)|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,P$1=function(n){return ("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/i:/fil|che|ra/i).test(n)};p.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(n){Object.defineProperty(p.prototype,n,{configurable:!0,get:function(){return this["UNSAFE_"+n]},set:function(t){Object.defineProperty(this,n,{configurable:!0,writable:!0,value:t});}});});var B=n$1.event;function H$1(){}function Z(){return this.cancelBubble}function Y(){return this.defaultPrevented}n$1.event=function(n){return B&&(n=B(n)),n.persist=H$1,n.isPropagationStopped=Z,n.isDefaultPrevented=Y,n.nativeEvent=n};var q$1={configurable:!0,get:function(){return this.class}},G=n$1.vnode;n$1.vnode=function(n){var t=n.type,e=n.props,r=e;if("string"==typeof t){for(var u in r={},e){var o=e[u];"value"===u&&"defaultValue"in e&&null==o||("defaultValue"===u&&"value"in e&&null==e.value?u="value":"download"===u&&!0===o?o="":/ondoubleclick/i.test(u)?u="ondblclick":/^onchange(textarea|input)/i.test(u+t)&&!P$1(e.type)?u="oninput":/^on(Ani|Tra|Tou|BeforeInp)/.test(u)?u=u.toLowerCase():W.test(u)?u=u.replace(/[A-Z0-9]/,"-$&").toLowerCase():null===o&&(o=void 0),r[u]=o);}"select"==t&&r.multiple&&Array.isArray(r.value)&&(r.value=w(e.children).forEach(function(n){n.props.selected=-1!=r.value.indexOf(n.props.value);})),"select"==t&&null!=r.defaultValue&&(r.value=w(e.children).forEach(function(n){n.props.selected=r.multiple?-1!=r.defaultValue.indexOf(n.props.value):r.defaultValue==n.props.value;})),n.props=r;}t&&e.class!=e.className&&(q$1.enumerable="className"in e,null!=e.className&&(r.class=e.className),Object.defineProperty(r,"className",q$1)),n.$$typeof=I$1,G&&G(n);};var J=n$1.__r;n$1.__r=function(n){J&&J(n),n.__c;};"object"==typeof performance&&"function"==typeof performance.now?performance.now.bind(performance):function(){return Date.now()}; + + var CLASS_PATTERN = /^class /; + + function isClass(fn) { + return CLASS_PATTERN.test(fn.toString()); + } + + function isArray$1(obj) { + return Object.prototype.toString.call(obj) === '[object Array]'; + } + + function hasOwnProp(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); + } + + function annotate() { + var args = Array.prototype.slice.call(arguments); + + if (args.length === 1 && isArray$1(args[0])) { + args = args[0]; + } + + var fn = args.pop(); + + fn.$inject = args; + + return fn; + } + + + // Current limitations: + // - can't put into "function arg" comments + // function /* (no parenthesis like this) */ (){} + // function abc( /* xx (no parenthesis like this) */ a, b) {} + // + // Just put the comment before function or inside: + // /* (((this is fine))) */ function(a, b) {} + // function abc(a) { /* (((this is fine))) */} + // + // - can't reliably auto-annotate constructor; we'll match the + // first constructor(...) pattern found which may be the one + // of a nested class, too. + + var CONSTRUCTOR_ARGS = /constructor\s*[^(]*\(\s*([^)]*)\)/m; + var FN_ARGS = /^(?:async )?(?:function\s*)?[^(]*\(\s*([^)]*)\)/m; + var FN_ARG = /\/\*([^*]*)\*\//m; + + function parseAnnotations(fn) { + + if (typeof fn !== 'function') { + throw new Error('Cannot annotate "' + fn + '". Expected a function!'); + } + + var match = fn.toString().match(isClass(fn) ? CONSTRUCTOR_ARGS : FN_ARGS); + + // may parse class without constructor + if (!match) { + return []; + } + + return match[1] && match[1].split(',').map(function(arg) { + match = arg.match(FN_ARG); + return match ? match[1].trim() : arg.trim(); + }) || []; + } + + function Module() { + var providers = []; + + this.factory = function(name, factory) { + providers.push([name, 'factory', factory]); + return this; + }; + + this.value = function(name, value) { + providers.push([name, 'value', value]); + return this; + }; + + this.type = function(name, type) { + providers.push([name, 'type', type]); + return this; + }; + + this.forEach = function(iterator) { + providers.forEach(iterator); + }; + + } + + function Injector(modules, parent) { + parent = parent || { + get: function(name, strict) { + currentlyResolving.push(name); + + if (strict === false) { + return null; + } else { + throw error('No provider for "' + name + '"!'); + } + } + }; + + var currentlyResolving = []; + var providers = this._providers = Object.create(parent._providers || null); + var instances = this._instances = Object.create(null); + + var self = instances.injector = this; + + var error = function(msg) { + var stack = currentlyResolving.join(' -> '); + currentlyResolving.length = 0; + return new Error(stack ? msg + ' (Resolving: ' + stack + ')' : msg); + }; + + /** + * Return a named service. + * + * @param {String} name + * @param {Boolean} [strict=true] if false, resolve missing services to null + * + * @return {Object} + */ + var get = function(name, strict) { + if (!providers[name] && name.indexOf('.') !== -1) { + var parts = name.split('.'); + var pivot = get(parts.shift()); + + while (parts.length) { + pivot = pivot[parts.shift()]; + } + + return pivot; + } + + if (hasOwnProp(instances, name)) { + return instances[name]; + } + + if (hasOwnProp(providers, name)) { + if (currentlyResolving.indexOf(name) !== -1) { + currentlyResolving.push(name); + throw error('Cannot resolve circular dependency!'); + } + + currentlyResolving.push(name); + instances[name] = providers[name][0](providers[name][1]); + currentlyResolving.pop(); + + return instances[name]; + } + + return parent.get(name, strict); + }; + + var fnDef = function(fn, locals) { + + if (typeof locals === 'undefined') { + locals = {}; + } + + if (typeof fn !== 'function') { + if (isArray$1(fn)) { + fn = annotate(fn.slice()); + } else { + throw new Error('Cannot invoke "' + fn + '". Expected a function!'); + } + } + + var inject = fn.$inject || parseAnnotations(fn); + var dependencies = inject.map(function(dep) { + if (hasOwnProp(locals, dep)) { + return locals[dep]; + } else { + return get(dep); + } + }); + + return { + fn: fn, + dependencies: dependencies + }; + }; + + var instantiate = function(Type) { + var def = fnDef(Type); + + var fn = def.fn, + dependencies = def.dependencies; + + // instantiate var args constructor + var Constructor = Function.prototype.bind.apply(fn, [ null ].concat(dependencies)); + + return new Constructor(); + }; + + var invoke = function(func, context, locals) { + var def = fnDef(func, locals); + + var fn = def.fn, + dependencies = def.dependencies; + + return fn.apply(context, dependencies); + }; + + + var createPrivateInjectorFactory = function(privateChildInjector) { + return annotate(function(key) { + return privateChildInjector.get(key); + }); + }; + + var createChild = function(modules, forceNewInstances) { + if (forceNewInstances && forceNewInstances.length) { + var fromParentModule = Object.create(null); + var matchedScopes = Object.create(null); + + var privateInjectorsCache = []; + var privateChildInjectors = []; + var privateChildFactories = []; + + var provider; + var cacheIdx; + var privateChildInjector; + var privateChildInjectorFactory; + for (var name in providers) { + provider = providers[name]; + + if (forceNewInstances.indexOf(name) !== -1) { + if (provider[2] === 'private') { + cacheIdx = privateInjectorsCache.indexOf(provider[3]); + if (cacheIdx === -1) { + privateChildInjector = provider[3].createChild([], forceNewInstances); + privateChildInjectorFactory = createPrivateInjectorFactory(privateChildInjector); + privateInjectorsCache.push(provider[3]); + privateChildInjectors.push(privateChildInjector); + privateChildFactories.push(privateChildInjectorFactory); + fromParentModule[name] = [privateChildInjectorFactory, name, 'private', privateChildInjector]; + } else { + fromParentModule[name] = [privateChildFactories[cacheIdx], name, 'private', privateChildInjectors[cacheIdx]]; + } + } else { + fromParentModule[name] = [provider[2], provider[1]]; + } + matchedScopes[name] = true; + } + + if ((provider[2] === 'factory' || provider[2] === 'type') && provider[1].$scope) { + /* jshint -W083 */ + forceNewInstances.forEach(function(scope) { + if (provider[1].$scope.indexOf(scope) !== -1) { + fromParentModule[name] = [provider[2], provider[1]]; + matchedScopes[scope] = true; + } + }); + } + } + + forceNewInstances.forEach(function(scope) { + if (!matchedScopes[scope]) { + throw new Error('No provider for "' + scope + '". Cannot use provider from the parent!'); + } + }); + + modules.unshift(fromParentModule); + } + + return new Injector(modules, self); + }; + + var factoryMap = { + factory: invoke, + type: instantiate, + value: function(value) { + return value; + } + }; + + modules.forEach(function(module) { + + function arrayUnwrap(type, value) { + if (type !== 'value' && isArray$1(value)) { + value = annotate(value.slice()); + } + + return value; + } + + // TODO(vojta): handle wrong inputs (modules) + if (module instanceof Module) { + module.forEach(function(provider) { + var name = provider[0]; + var type = provider[1]; + var value = provider[2]; + + providers[name] = [factoryMap[type], arrayUnwrap(type, value), type]; + }); + } else if (typeof module === 'object') { + if (module.__exports__) { + var clonedModule = Object.keys(module).reduce(function(m, key) { + if (key.substring(0, 2) !== '__') { + m[key] = module[key]; + } + return m; + }, Object.create(null)); + + var privateInjector = new Injector((module.__modules__ || []).concat([clonedModule]), self); + var getFromPrivateInjector = annotate(function(key) { + return privateInjector.get(key); + }); + module.__exports__.forEach(function(key) { + providers[key] = [getFromPrivateInjector, key, 'private', privateInjector]; + }); + } else { + Object.keys(module).forEach(function(name) { + if (module[name][2] === 'private') { + providers[name] = module[name]; + return; + } + + var type = module[name][0]; + var value = module[name][1]; + + providers[name] = [factoryMap[type], arrayUnwrap(type, value), type]; + }); + } + } + }); + + // public API + this.get = get; + this.invoke = invoke; + this.instantiate = instantiate; + this.createChild = createChild; + } + + function createInjector(bootstrapModules) { + const modules = [], + components = []; + + function hasModule(module) { + return modules.includes(module); + } + + function addModule(module) { + modules.push(module); + } + + function visit(module) { + if (hasModule(module)) { + return; + } + + (module.__depends__ || []).forEach(visit); + + if (hasModule(module)) { + return; + } + + addModule(module); + (module.__init__ || []).forEach(function (component) { + components.push(component); + }); + } + + bootstrapModules.forEach(visit); + const injector = new Injector(modules); + components.forEach(function (component) { + try { + injector[typeof component === 'string' ? 'get' : 'invoke'](component); + } catch (err) { + console.error('Failed to instantiate component'); + console.error(err.stack); + throw err; + } + }); + return injector; + } + + /** + * @param {string?} prefix + * + * @returns Element + */ + function createFormContainer(prefix = 'fjs') { + const container = document.createElement('div'); + container.classList.add(`${prefix}-container`); + return container; + } + + function findErrors(errors, path) { + return errors[pathStringify(path)]; + } + function pathStringify(path) { + if (!path) { + return ''; + } + + return path.join('.'); + } + const indices = {}; + function generateIndexForType(type) { + if (type in indices) { + indices[type]++; + } else { + indices[type] = 1; + } + + return indices[type]; + } + function generateIdForType(type) { + return `${type}${generateIndexForType(type)}`; + } + /** + * @template T + * @param {T} data + * @param {(this: any, key: string, value: any) => any} [replacer] + * @return {T} + */ + + function clone(data, replacer) { + return JSON.parse(JSON.stringify(data, replacer)); + } + + var FN_REF = '__fn'; + var DEFAULT_PRIORITY = 1000; + var slice = Array.prototype.slice; + /** + * A general purpose event bus. + * + * This component is used to communicate across a diagram instance. + * Other parts of a diagram can use it to listen to and broadcast events. + * + * + * ## Registering for Events + * + * The event bus provides the {@link EventBus#on} and {@link EventBus#once} + * methods to register for events. {@link EventBus#off} can be used to + * remove event registrations. Listeners receive an instance of {@link Event} + * as the first argument. It allows them to hook into the event execution. + * + * ```javascript + * + * // listen for event + * eventBus.on('foo', function(event) { + * + * // access event type + * event.type; // 'foo' + * + * // stop propagation to other listeners + * event.stopPropagation(); + * + * // prevent event default + * event.preventDefault(); + * }); + * + * // listen for event with custom payload + * eventBus.on('bar', function(event, payload) { + * console.log(payload); + * }); + * + * // listen for event returning value + * eventBus.on('foobar', function(event) { + * + * // stop event propagation + prevent default + * return false; + * + * // stop event propagation + return custom result + * return { + * complex: 'listening result' + * }; + * }); + * + * + * // listen with custom priority (default=1000, higher is better) + * eventBus.on('priorityfoo', 1500, function(event) { + * console.log('invoked first!'); + * }); + * + * + * // listen for event and pass the context (`this`) + * eventBus.on('foobar', function(event) { + * this.foo(); + * }, this); + * ``` + * + * + * ## Emitting Events + * + * Events can be emitted via the event bus using {@link EventBus#fire}. + * + * ```javascript + * + * // false indicates that the default action + * // was prevented by listeners + * if (eventBus.fire('foo') === false) { + * console.log('default has been prevented!'); + * }; + * + * + * // custom args + return value listener + * eventBus.on('sum', function(event, a, b) { + * return a + b; + * }); + * + * // you can pass custom arguments + retrieve result values. + * var sum = eventBus.fire('sum', 1, 2); + * console.log(sum); // 3 + * ``` + */ + + function EventBus() { + this._listeners = {}; // cleanup on destroy on lowest priority to allow + // message passing until the bitter end + + this.on('diagram.destroy', 1, this._destroy, this); + } + /** + * Register an event listener for events with the given name. + * + * The callback will be invoked with `event, ...additionalArguments` + * that have been passed to {@link EventBus#fire}. + * + * Returning false from a listener will prevent the events default action + * (if any is specified). To stop an event from being processed further in + * other listeners execute {@link Event#stopPropagation}. + * + * Returning anything but `undefined` from a listener will stop the listener propagation. + * + * @param {string|Array} events + * @param {number} [priority=1000] the priority in which this listener is called, larger is higher + * @param {Function} callback + * @param {Object} [that] Pass context (`this`) to the callback + */ + + EventBus.prototype.on = function (events, priority, callback, that) { + events = isArray(events) ? events : [events]; + + if (isFunction(priority)) { + that = callback; + callback = priority; + priority = DEFAULT_PRIORITY; + } + + if (!isNumber(priority)) { + throw new Error('priority must be a number'); + } + + var actualCallback = callback; + + if (that) { + actualCallback = bind(callback, that); // make sure we remember and are able to remove + // bound callbacks via {@link #off} using the original + // callback + + actualCallback[FN_REF] = callback[FN_REF] || callback; + } + + var self = this; + events.forEach(function (e) { + self._addListener(e, { + priority: priority, + callback: actualCallback, + next: null + }); + }); + }; + /** + * Register an event listener that is executed only once. + * + * @param {string} event the event name to register for + * @param {number} [priority=1000] the priority in which this listener is called, larger is higher + * @param {Function} callback the callback to execute + * @param {Object} [that] Pass context (`this`) to the callback + */ + + + EventBus.prototype.once = function (event, priority, callback, that) { + var self = this; + + if (isFunction(priority)) { + that = callback; + callback = priority; + priority = DEFAULT_PRIORITY; + } + + if (!isNumber(priority)) { + throw new Error('priority must be a number'); + } + + function wrappedCallback() { + wrappedCallback.__isTomb = true; + var result = callback.apply(that, arguments); + self.off(event, wrappedCallback); + return result; + } // make sure we remember and are able to remove + // bound callbacks via {@link #off} using the original + // callback + + + wrappedCallback[FN_REF] = callback; + this.on(event, priority, wrappedCallback); + }; + /** + * Removes event listeners by event and callback. + * + * If no callback is given, all listeners for a given event name are being removed. + * + * @param {string|Array} events + * @param {Function} [callback] + */ + + + EventBus.prototype.off = function (events, callback) { + events = isArray(events) ? events : [events]; + var self = this; + events.forEach(function (event) { + self._removeListener(event, callback); + }); + }; + /** + * Create an EventBus event. + * + * @param {Object} data + * + * @return {Object} event, recognized by the eventBus + */ + + + EventBus.prototype.createEvent = function (data) { + var event = new InternalEvent(); + event.init(data); + return event; + }; + /** + * Fires a named event. + * + * @example + * + * // fire event by name + * events.fire('foo'); + * + * // fire event object with nested type + * var event = { type: 'foo' }; + * events.fire(event); + * + * // fire event with explicit type + * var event = { x: 10, y: 20 }; + * events.fire('element.moved', event); + * + * // pass additional arguments to the event + * events.on('foo', function(event, bar) { + * alert(bar); + * }); + * + * events.fire({ type: 'foo' }, 'I am bar!'); + * + * @param {string} [name] the optional event name + * @param {Object} [event] the event object + * @param {...Object} additional arguments to be passed to the callback functions + * + * @return {boolean} the events return value, if specified or false if the + * default action was prevented by listeners + */ + + + EventBus.prototype.fire = function (type, data) { + var event, firstListener, returnValue, args; + args = slice.call(arguments); + + if (typeof type === 'object') { + data = type; + type = data.type; + } + + if (!type) { + throw new Error('no event type specified'); + } + + firstListener = this._listeners[type]; + + if (!firstListener) { + return; + } // we make sure we fire instances of our home made + // events here. We wrap them only once, though + + + if (data instanceof InternalEvent) { + // we are fine, we alread have an event + event = data; + } else { + event = this.createEvent(data); + } // ensure we pass the event as the first parameter + + + args[0] = event; // original event type (in case we delegate) + + var originalType = event.type; // update event type before delegation + + if (type !== originalType) { + event.type = type; + } + + try { + returnValue = this._invokeListeners(event, args, firstListener); + } finally { + // reset event type after delegation + if (type !== originalType) { + event.type = originalType; + } + } // set the return value to false if the event default + // got prevented and no other return value exists + + + if (returnValue === undefined && event.defaultPrevented) { + returnValue = false; + } + + return returnValue; + }; + + EventBus.prototype.handleError = function (error) { + return this.fire('error', { + error: error + }) === false; + }; + + EventBus.prototype._destroy = function () { + this._listeners = {}; + }; + + EventBus.prototype._invokeListeners = function (event, args, listener) { + var returnValue; + + while (listener) { + // handle stopped propagation + if (event.cancelBubble) { + break; + } + + returnValue = this._invokeListener(event, args, listener); + listener = listener.next; + } + + return returnValue; + }; + + EventBus.prototype._invokeListener = function (event, args, listener) { + var returnValue; + + if (listener.callback.__isTomb) { + return returnValue; + } + + try { + // returning false prevents the default action + returnValue = invokeFunction(listener.callback, args); // stop propagation on return value + + if (returnValue !== undefined) { + event.returnValue = returnValue; + event.stopPropagation(); + } // prevent default on return false + + + if (returnValue === false) { + event.preventDefault(); + } + } catch (e) { + if (!this.handleError(e)) { + console.error('unhandled error in event listener'); + console.error(e.stack); + throw e; + } + } + + return returnValue; + }; + /* + * Add new listener with a certain priority to the list + * of listeners (for the given event). + * + * The semantics of listener registration / listener execution are + * first register, first serve: New listeners will always be inserted + * after existing listeners with the same priority. + * + * Example: Inserting two listeners with priority 1000 and 1300 + * + * * before: [ 1500, 1500, 1000, 1000 ] + * * after: [ 1500, 1500, (new=1300), 1000, 1000, (new=1000) ] + * + * @param {string} event + * @param {Object} listener { priority, callback } + */ + + + EventBus.prototype._addListener = function (event, newListener) { + var listener = this._getListeners(event), + previousListener; // no prior listeners + + + if (!listener) { + this._setListeners(event, newListener); + + return; + } // ensure we order listeners by priority from + // 0 (high) to n > 0 (low) + + + while (listener) { + if (listener.priority < newListener.priority) { + newListener.next = listener; + + if (previousListener) { + previousListener.next = newListener; + } else { + this._setListeners(event, newListener); + } + + return; + } + + previousListener = listener; + listener = listener.next; + } // add new listener to back + + + previousListener.next = newListener; + }; + + EventBus.prototype._getListeners = function (name) { + return this._listeners[name]; + }; + + EventBus.prototype._setListeners = function (name, listener) { + this._listeners[name] = listener; + }; + + EventBus.prototype._removeListener = function (event, callback) { + var listener = this._getListeners(event), + nextListener, + previousListener, + listenerCallback; + + if (!callback) { + // clear listeners + this._setListeners(event, null); + + return; + } + + while (listener) { + nextListener = listener.next; + listenerCallback = listener.callback; + + if (listenerCallback === callback || listenerCallback[FN_REF] === callback) { + if (previousListener) { + previousListener.next = nextListener; + } else { + // new first listener + this._setListeners(event, nextListener); + } + } + + previousListener = listener; + listener = nextListener; + } + }; + /** + * A event that is emitted via the event bus. + */ + + + function InternalEvent() {} + + InternalEvent.prototype.stopPropagation = function () { + this.cancelBubble = true; + }; + + InternalEvent.prototype.preventDefault = function () { + this.defaultPrevented = true; + }; + + InternalEvent.prototype.init = function (data) { + assign(this, data || {}); + }; + /** + * Invoke function. Be fast... + * + * @param {Function} fn + * @param {Array} args + * + * @return {Any} + */ + + + function invokeFunction(fn, args) { + return fn.apply(null, args); + } + + class Validator { + validateField(field, value) { + const { + validate + } = field; + let errors = []; + + if (!validate) { + return errors; + } + + if (validate.pattern && value && !new RegExp(validate.pattern).test(value)) { + errors = [...errors, `Field must match pattern ${validate.pattern}.`]; + } + + if (validate.required && (typeof value === 'undefined' || value === '')) { + errors = [...errors, 'Field is required.']; + } + + if ('min' in validate && value && value < validate.min) { + errors = [...errors, `Field must have minimum value of ${validate.min}.`]; + } + + if ('max' in validate && value && value > validate.max) { + errors = [...errors, `Field must have maximum value of ${validate.max}.`]; + } + + if ('minLength' in validate && value && value.trim().length < validate.minLength) { + errors = [...errors, `Field must have minimum length of ${validate.minLength}.`]; + } + + if ('maxLength' in validate && value && value.trim().length > validate.maxLength) { + errors = [...errors, `Field must have maximum length of ${validate.maxLength}.`]; + } + + return errors; + } + + } + + var FormFieldRegistry = Map; + + class Importer { + /** + * @constructor + * @param { import('../core/FormFieldRegistry').default } formFieldRegistry + * @param { import('../render/FormFields').default } formFields + */ + constructor(formFieldRegistry, formFields) { + this._formFieldRegistry = formFieldRegistry; + this._formFields = formFields; + } + /** + * Import schema adding `_id`, `_parent` and `_path` information to each field and adding it to the form field registry. + * + * @param {any} schema + * @param {any} data + * + * @returns {Promise} + */ + + + importSchema(schema, data = {}) { + this._formFieldRegistry.clear(); // TODO: Add warnings + + + const warnings = []; + return new Promise((resolve, reject) => { + try { + this.importFormField(schema, data); + } catch (err) { + err.warnings = warnings; + reject(err); + } + + resolve({ + warnings + }); + }); + } + + importFormField(formField, data = {}, parentId) { + const { + components, + key, + type + } = formField; + + if (parentId) { + // Set form field parent + formField._parent = parentId; + } + + if (!this._formFields.get(type)) { + throw new Error(`form field of type <${type}> not supported`); + } + + if (key) { + this._formFieldRegistry.forEach(formField => { + if (formField.key === key) { + throw new Error(`form field with key <${key}> already exists`); + } + }); // Set form field path + + + formField._path = [key]; + } + + const _id = generateIdForType(type); // Set form field ID + + + formField._id = _id; + + this._formFieldRegistry.set(_id, formField); + + if (components) { + this.importFormFields(components, data, _id); + } + + return formField; + } + + importFormFields(components, data = {}, parentId) { + components.forEach(component => { + this.importFormField(component, data, parentId); + }); + } + + } + Importer.$inject = ['formFieldRegistry', 'formFields']; + + var importModule = { + importer: ['type', Importer] + }; + + const NODE_TYPE_TEXT = 3, + NODE_TYPE_ELEMENT = 1; + const ALLOWED_NODES = ['h1', 'h2', 'h3', 'h4', 'h5', 'span', 'em', 'a', 'p', 'div', 'ul', 'ol', 'li', 'hr', 'blockquote', 'img', 'pre', 'code', 'br', 'strong']; + const ALLOWED_ATTRIBUTES = ['align', 'alt', 'class', 'href', 'id', 'name', 'src']; + const ALLOWED_URI_PATTERN = /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i; // eslint-disable-line no-useless-escape + + const ATTR_WHITESPACE_PATTERN = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g; // eslint-disable-line no-control-regex + + const FORM_ELEMENT = document.createElement('form'); + /** + * Sanitize a HTML string and return the cleaned, safe version. + * + * @param {string} html + * @return {string} + */ + + function sanitizeHTML(html) { + const doc = new DOMParser().parseFromString(`\n
    ${html}`, 'text/html'); + doc.normalize(); + const element = doc.body.firstChild; + + if (element) { + sanitizeNode( + /** @type Element */ + element); + return new XMLSerializer().serializeToString(element); + } else { + // handle the case that document parsing + // does not work at all, due to HTML gibberish + return ''; + } + } + /** + * Recursively sanitize a HTML node, potentially + * removing it, its children or attributes. + * + * Inspired by https://github.com/developit/snarkdown/issues/70 + * and https://github.com/cure53/DOMPurify. Simplified + * for our use-case. + * + * @param {Element} node + */ + + function sanitizeNode(node) { + // allow text nodes + if (node.nodeType === NODE_TYPE_TEXT) { + return; + } // disallow all other nodes but Element + + + if (node.nodeType !== NODE_TYPE_ELEMENT) { + return node.remove(); + } + + const lcTag = node.tagName.toLowerCase(); // disallow non-whitelisted tags + + if (!ALLOWED_NODES.includes(lcTag)) { + return node.remove(); + } + + const attributes = node.attributes; // clean attributes + + for (let i = attributes.length; i--;) { + const attribute = attributes[i]; + const name = attribute.name; + const lcName = name.toLowerCase(); // normalize node value + + const value = attribute.value.trim(); + node.removeAttribute(name); + const valid = isValidAttribute(lcTag, lcName, value); + + if (valid) { + node.setAttribute(name, value); + } + } + + for (let i = node.childNodes.length; i--;) { + sanitizeNode( + /** @type Element */ + node.childNodes[i]); + } + } + /** + * Validates attributes for validity. + * + * @param {string} lcTag + * @param {string} lcName + * @param {string} value + * @return {boolean} + */ + + + function isValidAttribute(lcTag, lcName, value) { + // disallow most attributes based on whitelist + if (!ALLOWED_ATTRIBUTES.includes(lcName)) { + return false; + } // disallow "DOM clobbering" / polution of document and wrapping form elements + + + if ((lcName === 'id' || lcName === 'name') && (value in document || value in FORM_ELEMENT)) { + return false; + } // allow valid url links only + + + if (lcName === 'href' && !ALLOWED_URI_PATTERN.test(value.replace(ATTR_WHITESPACE_PATTERN, ''))) { + return false; + } + + return true; + } + + function formFieldClasses(type, errors = []) { + if (!type) { + throw new Error('type required'); + } + + const classes = ['fjs-form-field', `fjs-form-field-${type}`]; + + if (errors.length) { + classes.push('fjs-has-errors'); + } + + return classes.join(' '); + } + function prefixId(id) { + return `fjs-form-${id}`; + } + function markdownToHTML(markdown) { + const htmls = markdown.split(/(?:\r?\n){2,}/).map(line => /^((\d+.)|[><\s#-*])/.test(line) ? t(line) : `

    ${t(line)}

    `); + return htmls.join('\n\n'); + } // See https://github.com/developit/snarkdown/issues/70 + + function safeMarkdown(markdown) { + const html = markdownToHTML(markdown); + return sanitizeHTML(html); + } + + const type = 'button'; + function Button(props) { + const { + disabled, + field + } = props; + const { + action = 'submit' + } = field; + return o$1("div", { + class: formFieldClasses(type), + children: o$1("button", { + class: "fjs-button", + type: action, + disabled: disabled, + children: field.label + }) + }); + } + + Button.create = function (options = {}) { + const _id = generateIdForType(type); + + return { + action: 'submit', + _id, + key: _id, + label: this.label, + type, + ...options + }; + }; + + Button.type = type; + Button.label = 'Button'; + + function Description(props) { + const { + description + } = props; + + if (!description) { + return null; + } + + return o$1("div", { + class: "fjs-form-field-description", + children: description + }); + } + + function Errors(props) { + const { + errors + } = props; + + if (!errors.length) { + return null; + } + + return o$1("div", { + class: "fjs-form-field-error", + children: o$1("ul", { + children: errors.map(error => { + return o$1("li", { + children: error + }); + }) + }) + }); + } + + function Label(props) { + const { + id, + label, + required = false + } = props; + + if (!label) { + return null; + } + + return o$1("label", { + for: id, + class: "fjs-form-field-label", + children: [props.children, label, required && o$1("span", { + class: "fjs-asterix", + children: "*" + })] + }); + } + + const type$1 = 'checkbox'; + function Checkbox(props) { + const { + disabled, + errors = [], + field, + value = false + } = props; + const { + description, + _id, + label + } = field; + + const onChange = ({ + target + }) => { + props.onChange({ + field, + value: target.checked + }); + }; + + return o$1("div", { + class: formFieldClasses(type$1, errors), + children: [o$1(Label, { + id: prefixId(_id), + label: label, + required: false, + children: o$1("input", { + checked: value, + class: "fjs-input", + disabled: disabled, + id: prefixId(_id), + type: "checkbox", + onChange: onChange + }) + }), o$1(Description, { + description: description + }), o$1(Errors, { + errors: errors + })] + }); + } + + Checkbox.create = function (options = {}) { + const _id = generateIdForType(type$1); + + return { + _id, + key: _id, + label: this.label, + type: type$1, + ...options + }; + }; + + Checkbox.type = type$1; + Checkbox.label = 'Checkbox'; + + const FormRenderContext = q({ + Empty: props => { + return null; + }, + Children: props => { + return props.children; + }, + Element: props => { + return props.children; + } + }); + + /** + * @param {string} type + * @param {boolean} [strict] + * + * @returns {any} + */ + + function getService(type, strict) {} + + const FormContext = q({ + getService + }); + + function useService (type, strict) { + const { + getService + } = F(FormContext); + return getService(type, strict); + } + + const noop = () => false; + + function FormField(props) { + const { + field, + onChange + } = props; + const { + _path + } = field; + const formFields = useService('formFields'), + form = useService('form'); + + const { + data, + errors, + properties + } = form._getState(); + + const { + Element + } = F(FormRenderContext); + const FormFieldComponent = formFields.get(field.type); + + if (!FormFieldComponent) { + throw new Error(`cannot render field <${field.type}>`); + } + + const value = get(data, _path); + const fieldErrors = findErrors(errors, _path); + return o$1(Element, { + field: field, + children: o$1(FormFieldComponent, { ...props, + disabled: properties.readOnly || false, + errors: fieldErrors, + onChange: properties.readOnly ? noop : onChange, + value: value + }) + }); + } + + function Default(props) { + const { + Children, + Empty + } = F(FormRenderContext); + const { + field + } = props; + const { + _id + } = field; + const { + components = [] + } = field; + return o$1(Children, { + class: "fjs-vertical-layout", + field: field, + children: [components.map(field => { + return a(FormField, { ...props, + key: _id, + field: field + }); + }), components.length ? null : o$1(Empty, {})] + }); + } + + Default.create = function (options = {}) { + const _id = generateIdForType(this.type); + + return { + components: [], + _id, + label: this.label, + type: this.type, + ...options + }; + }; + + Default.type = 'default'; + Default.label = 'Default'; + + /** + * This file must not be changed or exchanged. + * + * @see http://bpmn.io/license for more information. + */ + + function Logo() { + return o$1("svg", { + xmlns: "http://www.w3.org/2000/svg", + viewBox: "0 0 14.02 5.57", + width: "53", + height: "21", + style: "vertical-align:middle", + children: [o$1("path", { + fill: "currentColor", + d: "M1.88.92v.14c0 .41-.13.68-.4.8.33.14.46.44.46.86v.33c0 .61-.33.95-.95.95H0V0h.95c.65 0 .93.3.93.92zM.63.57v1.06h.24c.24 0 .38-.1.38-.43V.98c0-.28-.1-.4-.32-.4zm0 1.63v1.22h.36c.2 0 .32-.1.32-.39v-.35c0-.37-.12-.48-.4-.48H.63zM4.18.99v.52c0 .64-.31.98-.94.98h-.3V4h-.62V0h.92c.63 0 .94.35.94.99zM2.94.57v1.35h.3c.2 0 .3-.09.3-.37v-.6c0-.29-.1-.38-.3-.38h-.3zm2.89 2.27L6.25 0h.88v4h-.6V1.12L6.1 3.99h-.6l-.46-2.82v2.82h-.55V0h.87zM8.14 1.1V4h-.56V0h.79L9 2.4V0h.56v4h-.64zm2.49 2.29v.6h-.6v-.6zM12.12 1c0-.63.33-1 .95-1 .61 0 .95.37.95 1v2.04c0 .64-.34 1-.95 1-.62 0-.95-.37-.95-1zm.62 2.08c0 .28.13.39.33.39s.32-.1.32-.4V.98c0-.29-.12-.4-.32-.4s-.33.11-.33.4z" + }), o$1("path", { + fill: "currentColor", + d: "M0 4.53h14.02v1.04H0zM11.08 0h.63v.62h-.63zm.63 4V1h-.63v2.98z" + })] + }); + } + + function Lightbox(props) { + const { + open + } = props; + + if (!open) { + return null; + } + + return o$1("div", { + class: "fjs-powered-by-lightbox", + style: "z-index: 100; position: fixed; top: 0; left: 0;right: 0; bottom: 0", + children: [o$1("div", { + class: "backdrop", + style: "width: 100%; height: 100%; background: rgba(40 40 40 / 20%)", + onClick: props.onBackdropClick + }), o$1("div", { + class: "notice", + style: "position: absolute; left: 50%; top: 40%; transform: translate(-50%); width: 260px; padding: 10px; background: white; box-shadow: 0 1px 4px rgba(0 0 0 / 30%); font-family: Helvetica, Arial, sans-serif; font-size: 14px; display: flex; line-height: 1.3", + children: [o$1("a", { + href: "https://bpmn.io", + target: "_blank", + rel: "noopener", + style: "margin: 15px 20px 15px 10px; align-self: center; color: #404040", + children: o$1(Logo, {}) + }), o$1("span", { + children: ["Web-based tooling for BPMN, DMN, and forms powered by ", o$1("a", { + href: "https://bpmn.io", + target: "_blank", + rel: "noopener", + children: "bpmn.io" + }), "."] + })] + })] + }); + } + + function Link(props) { + return o$1("div", { + class: "fjs-powered-by fjs-form-field", + style: "text-align: right", + children: o$1("a", { + href: "https://bpmn.io", + target: "_blank", + rel: "noopener", + class: "fjs-powered-by-link", + title: "Powered by bpmn.io", + style: "color: #404040", + onClick: props.onClick, + children: o$1(Logo, {}) + }) + }); + } + + function PoweredBy(props) { + const [open, setOpen] = l(false); + + function toggleOpen(open) { + return event => { + event.preventDefault(); + setOpen(open); + }; + } + + return o$1(y, { + children: [j$2(o$1(Lightbox, { + open: open, + onBackdropClick: toggleOpen(false) + }), document.body), o$1(Link, { + onClick: toggleOpen(true) + })] + }); + } + + const noop$1 = () => {}; + + function FormComponent(props) { + const form = useService('form'); + + const { + schema + } = form._getState(); + + const { + onSubmit = noop$1, + onReset = noop$1, + onChange = noop$1 + } = props; + + const handleSubmit = event => { + event.preventDefault(); + onSubmit(); + }; + + const handleReset = event => { + event.preventDefault(); + onReset(); + }; + + return o$1("form", { + class: "fjs-form", + onSubmit: handleSubmit, + onReset: handleReset, + children: [o$1(FormField, { + field: schema, + onChange: onChange + }), o$1(PoweredBy, {})] + }); + + // return o$1("form", { + // class: "fjs-form", + // onSubmit: handleSubmit, + // onReset: handleReset, + // children: [o$1(FormField, { + // field: schema, + // onChange: onChange + // })] + // }); + } + + const type$2 = 'number'; + function Number$1(props) { + const { + disabled, + errors = [], + field, + value + } = props; + const { + description, + _id, + label, + validate = {} + } = field; + const { + required + } = validate; + + const onChange = ({ + target + }) => { + const parsedValue = parseInt(target.value, 10); + props.onChange({ + field, + value: isNaN(parsedValue) ? undefined : parsedValue + }); + }; + + return o$1("div", { + class: formFieldClasses(type$2, errors), + children: [o$1(Label, { + id: prefixId(_id), + label: label, + required: required + }), o$1("input", { + class: "fjs-input", + disabled: disabled, + id: prefixId(_id), + onInput: onChange, + type: "number", + value: value + }), o$1(Description, { + description: description + }), o$1(Errors, { + errors: errors + })] + }); + } + + Number$1.create = function (options = {}) { + const _id = generateIdForType(type$2); + + return { + _id, + key: _id, + label: this.label, + type: type$2, + ...options + }; + }; + + Number$1.type = type$2; + Number$1.label = 'Number'; + + const type$3 = 'radio'; + function Radio(props) { + const { + disabled, + errors = [], + field, + value + } = props; + const { + description, + _id, + label, + validate = {}, + values + } = field; + const { + required + } = validate; + + const onChange = v => { + props.onChange({ + field, + value: v === value ? undefined : v + }); + }; + + return o$1("div", { + class: formFieldClasses(type$3, errors), + children: [o$1(Label, { + label: label, + required: required + }), values.map((v, index) => { + return o$1(Label, { + id: prefixId(`${_id}-${index}`), + label: v.label, + required: false, + children: o$1("input", { + checked: v.value === value, + class: "fjs-input", + disabled: disabled, + id: prefixId(`${_id}-${index}`), + type: "radio", + onClick: () => onChange(v.value) + }) + }); + }), o$1(Description, { + description: description + }), o$1(Errors, { + errors: errors + })] + }); + } + + Radio.create = function (options = {}) { + const _id = generateIdForType(type$3); + + return { + _id, + key: _id, + label: this.label, + type: type$3, + values: [{ + label: 'Value', + value: 'value' + }], + ...options + }; + }; + + Radio.type = type$3; + Radio.label = 'Radio'; + + const type$4 = 'select'; + function Select(props) { + const { + disabled, + errors = [], + field, + value + } = props; + const { + description, + _id, + label, + validate = {}, + values + } = field; + const { + required + } = validate; + + const onChange = ({ + target + }) => { + props.onChange({ + field, + value: target.value === '' ? undefined : target.value + }); + }; + + return o$1("div", { + class: formFieldClasses(type$4, errors), + children: [o$1(Label, { + label: label, + required: required + }), o$1("select", { + class: "fjs-select", + disabled: disabled, + id: prefixId(_id), + onChange: onChange, + value: value, + children: [o$1("option", { + value: "" + }), values.map((v, index) => { + return o$1("option", { + value: v.value, + children: v.label + }); + })] + }), o$1(Description, { + description: description + }), o$1(Errors, { + errors: errors + })] + }); + } + + Select.create = function (options = {}) { + const _id = generateIdForType(type$4); + + return { + _id, + key: _id, + label: this.label, + type: type$4, + values: [{ + label: 'Value', + value: 'value' + }], + ...options + }; + }; + + Select.type = type$4; + Select.label = '选择框'; + + const type$5 = 'text'; + function Text(props) { + const { + field + } = props; + const { + text = '' + } = field; + return o$1("div", { + class: formFieldClasses(type$5), + children: o$1(Markup, { + markup: safeMarkdown(text), + trim: false + }) + }); + } + + Text.create = function (options = {}) { + const _id = generateIdForType(type$5); + + return { + _id, + text: '# Text', + type: type$5, + ...options + }; + }; + + Text.type = type$5; + + const type$6 = 'textfield'; + function Textfield(props) { + const { + disabled, + errors = [], + field, + value = '' + } = props; + const { + description, + _id, + label, + validate = {} + } = field; + const { + required + } = validate; + + const onChange = ({ + target + }) => { + props.onChange({ + field, + value: target.value + }); + }; + + return o$1("div", { + class: formFieldClasses(type$6, errors), + children: [o$1(Label, { + id: prefixId(_id), + label: label, + required: required + }), o$1("input", { + class: "fjs-input", + disabled: disabled, + id: prefixId(_id), + onInput: onChange, + type: "text", + value: value + }), o$1(Description, { + description: description + }), o$1(Errors, { + errors: errors + })] + }); + } + + Textfield.create = function (options = {}) { + const _id = generateIdForType(type$6); + + return { + _id, + key: _id, + label: this.label, + type: type$6, + ...options + }; + }; + + Textfield.type = type$6; + Textfield.label = '文本框'; + + + /*** 学文自定义 多行文本框 start */ + + const type$7 = 'textarea'; + function TextArea(props) { + const { + disabled, + errors = [], + field, + value = '' + } = props; + const { + description, + _id, + label, + validate = {} + } = field; + const { + required + } = validate; + + const onChange = ({ + target + }) => { + props.onChange({ + field, + value: target.value + }); + }; + + return o$1("div", { + class: formFieldClasses(type$7, errors), + children: [o$1(Label, { + id: prefixId(_id), + label: label, + required: required + }), o$1("textarea", { + class: "fjs-textarea", + disabled: disabled, + id: prefixId(_id), + onInput: onChange, + //type: "text", + value: value + }), o$1(Description, { + description: description + }), o$1(Errors, { + errors: errors + })] + }); + } + + TextArea.create = function (options = {}) { + const _id = generateIdForType(type$7); + + return { + _id, + key: _id, + label: this.label, + type: type$7, + ...options + }; + }; + + TextArea.type = type$7; + TextArea.label = '多行文本框'; + + /*** 学文自定义 多行文本框 end */ + + /*** 学文自定义 日期文本框 start */ + + const type$8 = 'textdate'; + function TextDate(props) { + const { + disabled, + errors = [], + field, + value = '' + } = props; + const { + description, + _id, + label, + validate = {} + } = field; + const { + required + } = validate; + + const onChange = ({ + target + }) => { + props.onChange({ + field, + value: target.value + }); + }; + + return o$1("div", { + class: formFieldClasses(type$8, errors), + children: [o$1(Label, { + id: prefixId(_id), + label: label, + required: required + }), o$1("input", { + class: "fjs-input", + disabled: disabled, + id: prefixId(_id), + onInput: onChange, + type: "date", + value: value + }), o$1(Description, { + description: description + }), o$1(Errors, { + errors: errors + })] + }); + } + + TextDate.create = function (options = {}) { + const _id = generateIdForType(type$8); + + return { + _id, + key: _id, + label: this.label, + type: type$8, + ...options + }; + }; + + TextDate.type = type$8; + TextDate.label = '日期'; + + /*** 学文自定义 日期文本框 end */ + + /*** 学文自定义 时间文本框 start */ + + const type$9 = 'textdatetime'; + function TextDateTime(props) { + const { + disabled, + errors = [], + field, + value = '' + } = props; + const { + description, + _id, + label, + validate = {} + } = field; + const { + required + } = validate; + + const onChange = ({ + target + }) => { + props.onChange({ + field, + value: target.value + }); + }; + + return o$1("div", { + class: formFieldClasses(type$9, errors), + children: [o$1(Label, { + id: prefixId(_id), + label: label, + required: required + }), o$1("input", { + class: "fjs-input", + disabled: disabled, + id: prefixId(_id), + onInput: onChange, + type: "time", + value: value + }), o$1(Description, { + description: description + }), o$1(Errors, { + errors: errors + })] + }); + } + + TextDateTime.create = function (options = {}) { + const _id = generateIdForType(type$9); + + return { + _id, + key: _id, + label: this.label, + type: type$9, + ...options + }; + }; + + TextDateTime.type = type$9; + TextDateTime.label = '时间'; + + /*** 学文自定义 时间文本框 end */ + + const formFields = [Button, Checkbox, Default, Number$1, Radio, Select, Text, Textfield,TextArea,TextDate,TextDateTime]; + + class FormFields { + constructor() { + this._formFields = {}; + formFields.forEach(formField => { + const { + type + } = formField; + this.register(type, formField); + }); + } + + register(type, formField) { + this._formFields[type] = formField; + } + + get(type) { + return this._formFields[type]; + } + + } + + function Renderer(config, eventBus, form, injector) { + const App = () => { + const [state, setState] = l(form._getState()); + const formContext = { + getService(type, strict = true) { + return injector.get(type, strict); + } + + }; + eventBus.on('changed', newState => { + setState(newState); + }); + const onChange = A$1(update => form._update(update), [form]); + const { + properties + } = state; + const { + readOnly + } = properties; + const onSubmit = A$1(() => { + if (!readOnly) { + form.submit(); + } + }, [form, readOnly]); + const onReset = A$1(() => form.reset(), [form]); + const { + schema + } = state; + + if (!schema) { + return null; + } + + return o$1(FormContext.Provider, { + value: formContext, + children: o$1(FormComponent, { + onChange: onChange, + onSubmit: onSubmit, + onReset: onReset + }) + }); + }; + + const { + container + } = config; + eventBus.on('form.init', () => { + N(o$1(App, {}), container); + }); + eventBus.on('form.destroy', () => { + N(null, container); + }); + } + Renderer.$inject = ['config.renderer', 'eventBus', 'form', 'injector']; + + var renderModule = { + __init__: ['formFields', 'renderer'], + formFields: ['type', FormFields], + renderer: ['type', Renderer] + }; + + var core = { + __depends__: [importModule, renderModule], + eventBus: ['type', EventBus], + formFieldRegistry: ['type', FormFieldRegistry], + validator: ['type', Validator] + }; + + /** + * @typedef { import('didi').Injector } Injector + * + * @typedef { { [x: string]: any } } Data + * @typedef { { [x: string]: string[] } } Errors + * @typedef { any[] } Modules + * @typedef { ('readOnly' | string) } FormProperty + * @typedef { ('submit' | 'changed' | string) } FormEvent + * @typedef { { [x: string]: any } } FormProperties + * @typedef { any } Schema + * + * @typedef { { + * additionalModules?: Modules, + * container?: Element|string, + * injector?: Injector, + * modules?: Modules, + * properties?: FormProperties + * } } FormOptions + * + * @typedef { { + * data: Data, + * errors: Errors, + * properties: FormProperties, + * schema: Schema + * } } State + */ + + class Form { + /** + * @constructor + * @param {FormOptions} options + */ + constructor(options = {}) { + /** + * @private + * @type {Element} + */ + this._container = createFormContainer(); + const { + container, + injector = this._createInjector(options, this._container), + properties = {} + } = options; + /** + * @private + * @type {State} + */ + + this._state = { + data: null, + properties, + errors: {}, + schema: null + }; + /** + * @private + * @type {Data} + */ + + this._importedData = null; + this.get = injector.get; + this.invoke = injector.invoke; + this.get('eventBus').fire('form.init'); + + if (container) { + this.attachTo(container); + } + } + + destroy() { + this.get('eventBus').fire('form.destroy'); + + this._detach(false); + } + /** + * @param {Schema} schema + * @param {Data} [data] + */ + + + importSchema(schema, data = {}) { + this._importedData = null; + return new Promise((resolve, reject) => { + const importer = this.get('importer'); + schema = clone(schema); + data = clone(data); + importer.importSchema(schema, data).then(({ + warnings + }) => { + this._importedData = clone(data); + + this._setState({ + data, + errors: {}, + schema + }); + + resolve({ + warnings + }); + }).catch(err => { + reject(err); + }); + }); + } + /** + * @returns { { data: Data, errors: Errors } } + */ + + + submit() { + const { + properties + } = this._getState(); + + if (properties.readOnly) { + throw new Error('form is read-only'); + } + + const formFieldRegistry = this.get('formFieldRegistry'); // do not submit disabled form fields + + const data = Array.from(formFieldRegistry.values()).reduce((data, field) => { + const { + disabled, + _path + } = field; + + if (disabled) { + // strip disabled field value + set(data, _path, undefined); + } + + return data; + }, clone(this._getState().data)); + const errors = this.validate(); + + this._emit('submit', { + data, + errors + }); + + return { + data, + errors + }; + } + + reset() { + this._emit('reset'); + + this._setState({ + data: clone(this._importedData), + errors: {} + }); + } + /** + * @returns {Errors} + */ + + + validate() { + const formFieldRegistry = this.get('formFieldRegistry'), + validator = this.get('validator'); + + const { + data + } = this._getState(); + + const errors = Array.from(formFieldRegistry.values()).reduce((errors, field) => { + const { + disabled, + _path + } = field; + + if (disabled) { + return errors; + } + + const value = get(data, _path); + const fieldErrors = validator.validateField(field, value); + return set(errors, [pathStringify(_path)], fieldErrors.length ? fieldErrors : undefined); + }, + /** @type {Errors} */ + {}); + + this._setState({ + errors + }); + + return errors; + } + /** + * @param {Element|string} parentNode + */ + + + attachTo(parentNode) { + if (!parentNode) { + throw new Error('parentNode required'); + } + + this.detach(); + + if (isString(parentNode)) { + parentNode = document.querySelector(parentNode); + } + + const container = this._container; + parentNode.appendChild(container); + + this._emit('attach'); + } + + detach() { + this._detach(); + } + /** + * @param {boolean} [emit] + */ + + + _detach(emit = true) { + const container = this._container, + parentNode = container.parentNode; + + if (!parentNode) { + return; + } + + if (emit) { + this._emit('detach'); + } + + parentNode.removeChild(container); + } + /** + * @param {FormProperty} property + * @param {any} value + */ + + + setProperty(property, value) { + const properties = set(this._getState().properties, [property], value); + + this._setState({ + properties + }); + } + /** + * @param {FormEvent} type + * @param {Function} handler + */ + + + on(type, handler) { + this.get('eventBus').on(type, handler); + } + /** + * @param {FormEvent} type + * @param {Function} handler + */ + + + off(type, handler) { + this.get('eventBus').on(type, handler); + } + /** + * @param {FormOptions} options + * @param {Element} container + * + * @returns {Injector} + */ + + + _createInjector(options, container) { + const { + additionalModules = [], + modules = [] + } = options; + const config = { + renderer: { + container + } + }; + return createInjector([{ + config: ['value', config] + }, { + form: ['value', this] + }, core, ...modules, ...additionalModules]); + } + + _emit(type, data) { + this.get('eventBus').fire(type, data); + } + /** + * @param { { add?: boolean, field: any, remove?: number, value?: any } } update + */ + + + _update(update) { + const { + field, + value + } = update; + const { + _path + } = field; + + let { + data, + errors + } = this._getState(); + + const validator = this.get('validator'); + const fieldErrors = validator.validateField(field, value); + set(data, _path, value); + set(errors, [pathStringify(_path)], fieldErrors.length ? fieldErrors : undefined); + + this._setState({ + data: clone(data), + errors: clone(errors) + }); + } + + _getState() { + return this._state; + } + + _setState(state) { + this._state = { ...this._state, + ...state + }; + + this._emit('changed', this._getState()); + } + + } + + const schemaVersion = 1; + /** + * @typedef { import('didi').Injector } Injector + * + * @typedef { { [x: string]: any } } Data + * @typedef { any } Schema + * @typedef { any[] } Modules + * @typedef { { [x: string]: any } } FormPropertyOptions + * + * @typedef { { + * additionalModules?: Modules, + * container?: Element|string, + * data?: Data, + * injector?: Injector, + * modules?: Modules, + * properties?: FormPropertyOptions, + * schema: Schema + * } } FormViewerOptions + */ + + /** + * Create a form. + * + * @param {FormViewerOptions} options + * + * @return {Promise
    } + */ + + function createForm(options) { + const { + data, + schema, + ...rest + } = options; + const form = new Form(rest); + return form.importSchema(schema, data).then(function () { + return form; + }); + } + + exports.Form = Form; + exports.createForm = createForm; + exports.schemaVersion = schemaVersion; + + Object.defineProperty(exports, '__esModule', { value: true }); + + }))); \ No newline at end of file diff --git a/public/pages/property/assetImport/assetImport.js b/public/pages/property/assetImport/assetImport.js index 099fd747d..f2c4a5209 100755 --- a/public/pages/property/assetImport/assetImport.js +++ b/public/pages/property/assetImport/assetImport.js @@ -80,7 +80,6 @@ } }, function (json, res) { - //vm.menus = vm.refreshMenuActive(JSON.parse(json),0); if (res.status == 200) { //关闭model vc.toast("处理成功"); diff --git a/public/pages/property/newOaWorkflowForm/newOaWorkflowForm.html b/public/pages/property/newOaWorkflowForm/newOaWorkflowForm.html new file mode 100644 index 000000000..84b2ad203 --- /dev/null +++ b/public/pages/property/newOaWorkflowForm/newOaWorkflowForm.html @@ -0,0 +1,3 @@ +
    +
    +
    \ No newline at end of file diff --git a/public/pages/property/newOaWorkflowForm/newOaWorkflowForm.js b/public/pages/property/newOaWorkflowForm/newOaWorkflowForm.js new file mode 100644 index 000000000..7eab3ab0c --- /dev/null +++ b/public/pages/property/newOaWorkflowForm/newOaWorkflowForm.js @@ -0,0 +1,55 @@ +/** + 入驻小区 +**/ +(function (vc) { + var DEFAULT_PAGE = 1; + var DEFAULT_ROWS = 100; + vc.extends({ + data: { + newOaWorkflowFormInfo: { + formJson: {}, + conditions: { + } + } + }, + _initMethod: function () { + vc.component._listOaWorkflowForm(DEFAULT_PAGE, DEFAULT_ROWS); + }, + _initEvent: function () { + + vc.on('newOaWorkflowForm', 'listNewOaWorkflow', function (_param) { + vc.component._listNewOaWorkflows(DEFAULT_PAGE, DEFAULT_ROWS); + }); + }, + methods: { + _listOaWorkflowForm: function (_page, _rows) { + var param = { + params: { + page: 1, + row: 1, + flowId: vc.getParam('flowId') + } + }; + + //发送get请求 + vc.http.apiGet('/oaWorkflow/queryOaWorkflowForm', + param, + function (json, res) { + let _newOaWorkflowFormInfo = JSON.parse(json); + $that.newOaWorkflowFormInfo.formJson = JSON.parse(_newOaWorkflowFormInfo.data[0].formJson); + $that._initForm(); + }, function (errInfo, error) { + console.log('请求失败处理'); + } + ); + }, + _initForm: function () { + const container = document.querySelector('#form'); + FormViewer.createForm({ + container, + schema: $that.newOaWorkflowFormInfo.formJson + }); + } + } + }); +})(window.vc); diff --git a/public/pages/property/newOaWorkflowManage/newOaWorkflowManage.js b/public/pages/property/newOaWorkflowManage/newOaWorkflowManage.js index 8e8e73f42..347758456 100644 --- a/public/pages/property/newOaWorkflowManage/newOaWorkflowManage.js +++ b/public/pages/property/newOaWorkflowManage/newOaWorkflowManage.js @@ -45,7 +45,30 @@ ); }, newFlow: function (_flow) { - console.log('流程',_flow); + //判断流程是否已部署 + var param = { + params: { + page: 1, + row: 1, + flowId: _flow.flowId, + state: 'C' + } + }; + //发送get请求 + vc.http.apiGet('/oaWorkflow/queryOaWorkflow', + param, + function (json, res) { + var _oaWorkflowManageInfo = JSON.parse(json); + let oaWorkflows = _oaWorkflowManageInfo.data; + if (oaWorkflows.length < 1) { + vc.toast('流程未部署'); + return; + } + vc.jumpToPage('/form.html#/pages/property/newOaWorkflowForm?flowId=' + _flow.flowId) + }, function (errInfo, error) { + console.log('请求失败处理'); + } + ); } } });