UNPKG

@wufengteam/baguaeditor

Version:

低零融合编辑器封装

1,446 lines (1,430 loc) 3.28 MB
import { wufengController } from '@wufengteam/core'; import { ContainerDropBox, BOFramer, createPageWithValidate, createCompWithDSLNode, SiderDragBox, useCreateActionData, createPageTemplate, createCompTemplate, createId as createId$2, EditorView, useExportFieldChange } from '@lingxiteam/editor'; export * from '@lingxiteam/editor'; import 'antd/es/form/style'; import _Form from 'antd/es/form'; import { jsx, jsxs, Fragment } from 'react/jsx-runtime'; import 'antd/es/col/style'; import _Col from 'antd/es/col'; import 'antd/es/row/style'; import _Row from 'antd/es/row'; import 'antd/es/modal/style'; import _Modal from 'antd/es/modal'; import 'antd/es/message/style'; import _message from 'antd/es/message'; import React, { useState, useEffect, useMemo, createContext, useContext, useReducer, useCallback, useImperativeHandle, useRef, forwardRef } from 'react'; import classNames from 'classnames'; import { useEditContext } from '@lingxiteam/editor/es/utils/EditContext'; import { getCompCreator } from '@lingxiteam/editor/es/hooks/useCompCreators'; import { pinyin } from 'pinyin-pro'; import 'antd/es/button/style'; import _Button from 'antd/es/button'; import 'antd/es/space/style'; import _Space from 'antd/es/space'; import 'antd/es/spin/style'; import _Spin from 'antd/es/spin'; import 'antd/es/input/style'; import _Input from 'antd/es/input'; import Icon, { LeftOutlined, QuestionCircleOutlined, CloseOutlined, CopyOutlined, UserOutlined, PlusOutlined, DownOutlined, PlusCircleTwoTone, DeleteFilled, PlusCircleFilled, EditOutlined, SearchOutlined, DeleteOutlined, PlusCircleOutlined, MoreOutlined, CaretDownOutlined, CaretRightOutlined, SettingOutlined, FileSearchOutlined, ExclamationCircleFilled, QuestionCircleFilled, CloseCircleFilled, CaretUpOutlined, RightOutlined } from '@ant-design/icons'; import 'antd/es/layout/style'; import _Layout from 'antd/es/layout'; import 'antd/es/card/style'; import _Card from 'antd/es/card'; import 'antd/es/empty/style'; import _Empty from 'antd/es/empty'; import 'antd/es/tag/style'; import _Tag from 'antd/es/tag'; import 'antd/es/tooltip/style'; import _Tooltip from 'antd/es/tooltip'; import 'antd/es/checkbox/style'; import _Checkbox from 'antd/es/checkbox'; import 'antd/es/tabs/style'; import _Tabs from 'antd/es/tabs'; import { useSetState, useDebounceFn } from 'ahooks'; import difference from 'lodash.difference'; import 'antd/es/list/style'; import _List from 'antd/es/list'; import 'antd/es/skeleton/style'; import _Skeleton from 'antd/es/skeleton'; import InfiniteScroll from 'react-infinite-scroll-component'; import 'antd/es/tree/style'; import _Tree from 'antd/es/tree'; import 'antd/es/divider/style'; import _Divider from 'antd/es/divider'; import 'antd/es/radio/style'; import _Radio from 'antd/es/radio'; import ReactQuill from 'react-quill'; import 'react-quill/dist/quill.snow.css'; import 'antd/es/avatar/style'; import _Avatar from 'antd/es/avatar'; import 'antd/es/menu/style'; import _Menu from 'antd/es/menu'; import 'antd/es/table/style'; import _Table from 'antd/es/table'; import 'antd/es/select/style'; import _Select from 'antd/es/select'; import 'antd/es/dropdown/style'; import _Dropdown from 'antd/es/dropdown'; import 'antd/es/drawer/style'; import _Drawer from 'antd/es/drawer'; import cloneDeep from 'lodash.clonedeep'; import { v4 } from 'uuid'; import 'antd/es/input-number/style'; import _InputNumber from 'antd/es/input-number'; import 'antd/es/tree-select/style'; import _TreeSelect from 'antd/es/tree-select'; import 'antd/es/switch/style'; import _Switch from 'antd/es/switch'; import 'antd/es/typography/style'; import _Typography from 'antd/es/typography'; import 'antd/es/popover/style'; import _Popover from 'antd/es/popover'; import 'antd/es/popconfirm/style'; import _Popconfirm from 'antd/es/popconfirm'; import chunk from 'lodash.chunk'; import { useDrop, useDrag, DndProvider } from 'react-dnd'; import { HTML5Backend } from 'react-dnd-html5-backend'; import update from 'immutability-helper'; import { Base64 } from 'js-base64'; import { getLocationPrefix } from '@wufengteam/utils'; import 'antd/es/carousel/style'; import _Carousel from 'antd/es/carousel'; import 'antd/es/upload/style'; import _Upload from 'antd/es/upload'; import 'antd/es/cascader/style'; import _Cascader from 'antd/es/cascader'; import 'antd/es/date-picker/style'; import _DatePicker from 'antd/es/date-picker'; import moment from 'moment'; import AttrFilterForm from '@wufengteam/attrfilter'; import copy from 'copy-to-clipboard'; import 'antd/es/page-header/style'; import _PageHeader from 'antd/es/page-header'; import Qrcode from 'qrcode.react'; import 'braft-editor/dist/index.css'; import 'antd/es/collapse/style'; import _Collapse from 'antd/es/collapse'; import BraftEditor from 'braft-editor'; import ImgCrop from 'antd-img-crop'; import { SketchPicker } from 'react-color'; import 'antd/es/steps/style'; import _Steps from 'antd/es/steps'; import 'antd/es/descriptions/style'; import _Descriptions from 'antd/es/descriptions'; 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 ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _regeneratorRuntime() { _regeneratorRuntime = function () { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function (t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function (t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(typeof e + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function (e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function () { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function (e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function (t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function (t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function (t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function (t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function (e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; } function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); } function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } 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 _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } 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 _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function () {}; return { s: F, n: function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function (e) { throw e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function () { it = it.call(o); }, n: function () { var step = it.next(); normalCompletion = step.done; return step; }, e: function (e) { didErr = true; err = e; }, f: function () { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } var Platform = { WEB: 'web', H5: 'h5' }; var FormLayout = function FormLayout(_ref) { var _ref$columns = _ref.columns, columns = _ref$columns === void 0 ? 1 : _ref$columns, children = _ref.children, _ref$platform = _ref.platform, platform = _ref$platform === void 0 ? Platform.WEB : _ref$platform, style = _ref.style; var span = 24 / columns; var gutter = 16; return jsx(_Row, { gutter: gutter, style: style, children: Array.isArray(children) ? children.map(function (component, index) { var _span = component.props.span; // 如果组件自己有设置宽度,那么使用组件设置的,否则,使用快速排版的 span // 如果不是 pc 平台,那么 span 都等 24 var spanToApplay = platform !== Platform.WEB ? 24 : _span || span; return jsx(_Col, { span: spanToApplay, children: component }, component.key || index); }) : children }); }; var FormLayoutType = 'FormLayout'; var FormLayout$1 = function FormLayout$1(props) { var _props$columns = props.columns, columns = _props$columns === void 0 ? 1 : _props$columns, children = props.children, _component = props._component, style = props.style, isMobile = props.isMobile; var platform = props.platform; if (!platform) { // 优先使用 platform 的值,如果 platform 值不存在,那么使用 isMobile platform = isMobile ? Platform.H5 : Platform.WEB; } return jsx(ContainerDropBox, { _component: _component, style: _objectSpread2({ padding: '12px' }, style), children: jsx(_Form, { layout: "vertical", children: jsx(FormLayout, { columns: columns, platform: platform, children: children }) }) }); }; /* eslint-disable no-console */ wufengController.registerComponent(FormLayout$1, { type: FormLayoutType, label: '表单布局', isContainer: true, props: { columns: 1 }, todoProps: {}, style: {} }); /** 移动端业务组件 */ wufengController.registerComponent(BOFramer, { compLib: '@/components', compType: 4, isBusiObjContainer: false, isContainer: true, platform: 'h5', type: 'BOFramerH5', label: '业务组件', props: { name: '业务组件', message: '提示文字', type: 'info', showIcon: true, visible: true, appBusiCompId: '' }, style: { margin: '0 0 12px 0' }, groupsName: '容器', todoProps: { useEffectLoading: { label: '加载中效果', type: 'Switch', groupsName: '基础', istodoBind: false, props: { description: '当开启后,业务组件加载完成(所有异步动作执行结束后,会取消loading)' } }, appBusiCompId: { label: 'xxx', type: 'Input', props: { dependProps: { noShow: true } } }, visible: { label: '是否显示', type: 'Switch', groupsName: '基础', props: { defaultValue: true } }, busiCompStates: { label: '组件状态', type: 'SetBusiCompStates', groupsName: '状态', props: { terminal: ['mobile'] } } }, icon: 'BOFramer' }); /** PC端业务组件 */ wufengController.registerComponent(BOFramer, { icon: 'BOFramer', compLib: '@/components', compType: 4, platform: 'pc', type: 'BOFramer', alias: 'null', label: '业务组件', props: { name: '业务组件', visible: true }, style: { margin: '0 0 12px 0' }, groupsName: '容器', todoProps: { name: { label: '名称', type: 'Input', groupsName: '基础', props: {} }, selfSpan: { label: '列占比', type: 'ColSpan', props: { dependProps: { noShow: false } } }, visible: { label: '是否显示', type: 'Switch', groupsName: '基础', props: { defaultValue: true } }, busiCompParamSet: { label: '组件参数', type: 'BusiCompParamSet', groupsName: '基础', props: {} } } }); var ignoreComponents = ['DForm', 'Form']; var getOptions = function getOptions(comProps) { var _comProps$options, _comProps$staticData, _comProps$treeData; var childrenTranslation = function childrenTranslation(children, _ref) { var key = _ref.key, value = _ref.value; return children === null || children === void 0 ? void 0 : children.map(function (item) { var list = { title: item[key], value: item[value] }; if (Array.isArray(item.children) && item.children) { return _objectSpread2(_objectSpread2({}, list), {}, { children: childrenTranslation(item.children, { key: 'title', value: 'value' }) }); } return _objectSpread2(_objectSpread2({}, list), {}, { children: [] }); }); }; if ((comProps === null || comProps === void 0 ? void 0 : comProps.options) && (comProps === null || comProps === void 0 ? void 0 : (_comProps$options = comProps.options) === null || _comProps$options === void 0 ? void 0 : _comProps$options.length) > 0) { var _comProps$options2; return comProps === null || comProps === void 0 ? void 0 : (_comProps$options2 = comProps.options) === null || _comProps$options2 === void 0 ? void 0 : _comProps$options2.map(function (item) { var _item$children; // 如果有children说明组件是树型组件 if ((item === null || item === void 0 ? void 0 : (_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) > 0) { return { title: item.title, value: item.value, children: childrenTranslation(item.children, { key: 'title', value: 'value' }) }; } // 就是普通的自定义数据 return { title: item.title || item.label, value: item.value }; }); } // 低代码又返回一个新格式 if (Array.isArray(comProps === null || comProps === void 0 ? void 0 : (_comProps$staticData = comProps.staticData) === null || _comProps$staticData === void 0 ? void 0 : _comProps$staticData.data)) { var _comProps$staticData2, _comProps$staticData3; return comProps === null || comProps === void 0 ? void 0 : (_comProps$staticData2 = comProps.staticData) === null || _comProps$staticData2 === void 0 ? void 0 : (_comProps$staticData3 = _comProps$staticData2.data) === null || _comProps$staticData3 === void 0 ? void 0 : _comProps$staticData3.map(function (item) { var _item$children2; // 如果有children说明组件是树型组件 if ((item === null || item === void 0 ? void 0 : (_item$children2 = item.children) === null || _item$children2 === void 0 ? void 0 : _item$children2.length) > 0) { return { title: item.title || item.label, value: item.value, children: childrenTranslation(item.children, { key: 'title', value: 'value' }) }; } return { // 返回格式又从label变成title title: item.title || item.label, value: item.value }; }); } // 说明是绑定静态数据 if (comProps === null || comProps === void 0 ? void 0 : comProps.staticData) { var _comProps$staticData4, _comProps$staticData5; var selectedKeyTags = comProps === null || comProps === void 0 ? void 0 : (_comProps$staticData4 = comProps.staticData) === null || _comProps$staticData4 === void 0 ? void 0 : (_comProps$staticData5 = _comProps$staticData4.data) === null || _comProps$staticData5 === void 0 ? void 0 : _comProps$staticData5.selectedKeyTags; return selectedKeyTags === null || selectedKeyTags === void 0 ? void 0 : selectedKeyTags.map(function (item) { return { title: item.attrValueName, value: item.attrValue }; }); } // 说明是是树绑定 if ((comProps === null || comProps === void 0 ? void 0 : comProps.treeData) && (comProps === null || comProps === void 0 ? void 0 : (_comProps$treeData = comProps.treeData) === null || _comProps$treeData === void 0 ? void 0 : _comProps$treeData.length) > 0) { var _comProps$treeData2; return comProps === null || comProps === void 0 ? void 0 : (_comProps$treeData2 = comProps.treeData) === null || _comProps$treeData2 === void 0 ? void 0 : _comProps$treeData2.map(function (item) { return { title: item.title, value: item.value, children: childrenTranslation(item.children, { key: 'title', value: 'value' }) }; }); } // 如果返回空说明是否需要去适配 return []; }; var DATE_COMPONENTS = ['DatePicker', 'TimePicker', 'RangePicker', 'DformDate']; var getDateFormat = function getDateFormat() { var compProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var _ref2 = compProps || {}, format = _ref2.format, formatter = _ref2.formatter; var result = format || formatter || 'YYYY-MM-DD HH:mm:ss'; result = result.replace('YYYY', 'yyyy').replace('DD', 'dd'); return result; }; /** * 解析 pageData 中的表单字段 * @param pageData * @returns */ function extractFormData(pageData, oldPageData) { var _oldPageData$formData; if (!Array.isArray(pageData === null || pageData === void 0 ? void 0 : pageData.components)) { return []; } var prefixMap = {}; var bfidMap = {}; if (Array.isArray(oldPageData === null || oldPageData === void 0 ? void 0 : oldPageData.formData) && (oldPageData === null || oldPageData === void 0 ? void 0 : (_oldPageData$formData = oldPageData.formData) === null || _oldPageData$formData === void 0 ? void 0 : _oldPageData$formData.length) > 0) { oldPageData.formData.forEach(function (item) { if (item === null || item === void 0 ? void 0 : item.prefix) { prefixMap[item.prefix] = true; if (item === null || item === void 0 ? void 0 : item.parentReference) { bfidMap[item === null || item === void 0 ? void 0 : item.parentReference] = item === null || item === void 0 ? void 0 : item.prefix; } } }); } function findFields(components) { var fields = []; components.forEach(function (comp) { var _ref3 = comp || {}, compType = _ref3.compType, type = _ref3.type, _ref3$props = _ref3.props, props = _ref3$props === void 0 ? {} : _ref3$props; if ("".concat(compType) === '2' && !ignoreComponents.includes(type || '')) { var _props$staticData2, _props$treeData, _props$treeData$, _props$options, _props$options$; var field = { label: props.name || '', name: (props === null || props === void 0 ? void 0 : props.fieldName) || (props === null || props === void 0 ? void 0 : props.fieldProps) || '', nameAlias: (props === null || props === void 0 ? void 0 : props.fieldNameAlias) || (props === null || props === void 0 ? void 0 : props.fieldName) || (props === null || props === void 0 ? void 0 : props.fieldProps) || '', options: getOptions(props), component: comp }; // 解决联级组件h5无法正常展示下拉选项 if (props.fieldName.includes('Cascader_')) { var _props$staticData; props.options = (props === null || props === void 0 ? void 0 : props.options) || (props === null || props === void 0 ? void 0 : (_props$staticData = props.staticData) === null || _props$staticData === void 0 ? void 0 : _props$staticData.data) || []; } if ((props === null || props === void 0 ? void 0 : props.precision) || (props === null || props === void 0 ? void 0 : props.precision) === 0) { field.decimalDigits = props.precision; } if (props === null || props === void 0 ? void 0 : props.maskRule) { field.maskRule = props.maskRule; } // 日期类型组件需要传日期格式 if (DATE_COMPONENTS.includes(type)) { field.dateFormat = getDateFormat(props); } if ((_props$staticData2 = props.staticData) === null || _props$staticData2 === void 0 ? void 0 : _props$staticData2.extraData) { var _props$staticData3; fields.push(_objectSpread2(_objectSpread2({}, field), {}, { extraData: (_props$staticData3 = props.staticData) === null || _props$staticData3 === void 0 ? void 0 : _props$staticData3.extraData })); } else if ((_props$treeData = props.treeData) === null || _props$treeData === void 0 ? void 0 : (_props$treeData$ = _props$treeData[0]) === null || _props$treeData$ === void 0 ? void 0 : _props$treeData$.extraData) { var _props$treeData2, _props$treeData2$; fields.push(_objectSpread2(_objectSpread2({}, field), {}, { extraData: (_props$treeData2 = props.treeData) === null || _props$treeData2 === void 0 ? void 0 : (_props$treeData2$ = _props$treeData2[0]) === null || _props$treeData2$ === void 0 ? void 0 : _props$treeData2$.extraData })); } else if ((_props$options = props.options) === null || _props$options === void 0 ? void 0 : (_props$options$ = _props$options[0]) === null || _props$options$ === void 0 ? void 0 : _props$options$.extraData) { var _props$options2, _props$options2$; fields.push(_objectSpread2(_objectSpread2({}, field), {}, { extraData: (_props$options2 = props.options) === null || _props$options2 === void 0 ? void 0 : (_props$options2$ = _props$options2[0]) === null || _props$options2$ === void 0 ? void 0 : _props$options2$.extraData })); } else { fields.push(field); } } if ("".concat(compType) === '4' && (type === 'BOFramer' || type === 'BOFramerH5')) { // @ts-ignore var _comp$formData = comp.formData, formData = _comp$formData === void 0 ? [] : _comp$formData; if (Array.isArray(formData) && formData.length > 0) { var formData2 = formData.map(function (item) { var _item$component, _item$component$props, _item$component2, _item$component3; var uniquePrefixGenerated = false; var prefix = ''; console.log(bfidMap, comp.id, bfidMap[comp.id]); if ((comp === null || comp === void 0 ? void 0 : comp.id) && bfidMap[comp.id]) { prefix = bfidMap[comp.id]; } else { while (!uniquePrefixGenerated) { var num = Math.floor(Math.random() * 90 + 10); prefix = "bf".concat(num); if (prefixMap[prefix]) { uniquePrefixGenerated = false; } else { prefixMap[prefix] = true; bfidMap[comp.id] = prefix; uniquePrefixGenerated = true; } } } return { label: (item === null || item === void 0 ? void 0 : (_item$component = item.component) === null || _item$component === void 0 ? void 0 : (_item$component$props = _item$component.props) === null || _item$component$props === void 0 ? void 0 : _item$component$props.name) || (item === null || item === void 0 ? void 0 : item.label), nameAlias: "".concat(prefix, "_").concat(item === null || item === void 0 ? void 0 : item.name), name: "".concat(prefix, "_").concat(item === null || item === void 0 ? void 0 : (_item$component2 = item.component) === null || _item$component2 === void 0 ? void 0 : _item$component2.id), parentReference: comp === null || comp === void 0 ? void 0 : comp.id, prefix: prefix, compType: item === null || item === void 0 ? void 0 : (_item$component3 = item.component) === null || _item$component3 === void 0 ? void 0 : _item$component3.type, component: item === null || item === void 0 ? void 0 : item.component, options: item === null || item === void 0 ? void 0 : item.options }; }); fields = fields.concat(formData2); } } // 当组件类型为子表单时候不解析其子组件 if (type !== 'SubForm' && Array.isArray(comp === null || comp === void 0 ? void 0 : comp.components)) { var _fields; // @ts-ignore (_fields = fields).push.apply(_fields, _toConsumableArray(findFields(comp === null || comp === void 0 ? void 0 : comp.components))); } }); return fields; } var _pageData$components = pageData.components, components = _pageData$components === void 0 ? [] : _pageData$components; // @ts-ignore return findFields(components); } /** * 平台类型 */ var Platform$1; (function (Platform) { Platform["pc"] = "pc"; Platform["h5"] = "h5"; })(Platform$1 || (Platform$1 = {})); /** * 终端类型,服务端用到 */ var TerminalType; (function (TerminalType) { TerminalType["PC"] = "PC"; TerminalType["APP"] = "APP"; })(TerminalType || (TerminalType = {})); // 获取指定位数的数字随机数 var getRandomNum = function getRandomNum() { var bit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 4; var originArr = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']; return new Array(bit).fill(0).map(function () { var length = originArr === null || originArr === void 0 ? void 0 : originArr.length; var count = Math.floor(Math.random() * length); return originArr[count]; }).join(''); }; /** * 根据配置生成页面 DSL * @param config PageGenerateConfig * @returns */ function generatePage(config) { var pageName = config.pageName, _config$terminalType = config.terminalType, terminalType = _config$terminalType === void 0 ? TerminalType.PC : _config$terminalType, fields = config.fields, _config$isNeedDSLQuer = config.isNeedDSLQuery, isNeedDSLQuery = _config$isNeedDSLQuer === void 0 ? false : _config$isNeedDSLQuer; var platform = _defineProperty(_defineProperty({}, TerminalType.APP, Platform$1.h5), TerminalType.PC, Platform$1.pc)[terminalType]; var path = pinyin(pageName, { toneType: 'none', type: 'array' }).join('').split('/').join(''); path = "/".concat(path).concat(getRandomNum()); var pageData = createPageWithValidate({ pagePath: path, pageName: pageName, terminalType: terminalType }, { platform: platform, isValidate: false }); var formType = terminalType === TerminalType.PC ? 'Form' : 'DForm'; var formComp = createCompWithDSLNode({ type: formType, platform: platform, events: [], attribute: {} }, { parentNode: pageData.rootNode, dslQuery: pageData }); fields.forEach(function (field) { var label = field.label, compName = field.compName, staticData = field.staticData, _field$precision = field.precision, precision = _field$precision === void 0 ? 0 : _field$precision; var compNode = createCompWithDSLNode({ type: compName, platform: platform, events: [], attribute: {} }, { parentNode: formComp, dslQuery: pageData }); if (!compNode) return; // 如果是数字输入框的,有传入小数位数的,则将其设置到属性里,否则,传入的是小数,dsl是当整数接,会报错 if (precision && compName === 'InputNumber') { compNode.setProps({ name: label, title: label, precision: precision }); } else { compNode.setProps({ name: label, title: label }); } switch (terminalType) { case TerminalType.APP: { compNode.setProps({ fieldProps: compNode.getAttribute.id }); break; } case TerminalType.PC: { compNode.setProps({ fieldName: compNode.id, fieldNameAlias: compNode.id.toLowerCase(), staticData: staticData, options: staticData === null || staticData === void 0 ? void 0 : staticData.data }); break; } } }); var dslDsl = pageData.toJSON(); // @ts-ignore dslDsl.formData = extractFormData(dslDsl).map(function (item) { var retObj = { label: item.label, name: item.nameAlias, compCode: item.name, // 低代码组件标识是 compName compType: item.component.type || item.component.compName, options: (item === null || item === void 0 ? void 0 : item.options) || [], extraData: (item === null || item === void 0 ? void 0 : item.extraData) || {} }; // 若是有传小数位数,则将小数位数保存在formData里 if (item === null || item === void 0 ? void 0 : item.decimalDigits) { retObj.decimalDigits = item.decimalDigits; } return retObj; }); if (isNeedDSLQuery) { return { DSLQuery: pageData, dslDsl: dslDsl }; } return dslDsl; } var isZheJiangEnv = function isZheJiangEnv() { return window.location.origin.indexOf('zj.chinamobile') !== -1; }; // 配置态前缀 var requestConfigPrefix = function requestConfigPrefix() { var isDev = process.env.NODE_ENV === 'development'; var prefix = ''; if (isZheJiangEnv()) return prefix; if (isDev) { prefix = '/api'; } else { prefix = '../api'; } return prefix; }; function resolveConfigRequestPath(path) { if (!path) { return ''; } return "".concat(requestConfigPrefix(), "/").concat(path).replace(/(?!^)\/\//g, '/'); } // 生成随机id var createId = function createId(prefix, id) { var slength = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 12; var uid = id; if (!uid) { uid = "".concat(Math.random()).slice(slength); } return prefix ? "".concat(prefix, "_").concat(uid) : uid; }; var createIntId = function createIntId() { var length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 18; return +(Date.now() + createId()).slice(0, length); }; var TabKeys; (function (TabKeys) { TabKeys["formDesign"] = "formDesign"; TabKeys["formSetting"] = "formSetting"; TabKeys["formPublish"] = "formPublish"; TabKeys["assignPermission"] = "assignPermission"; TabKeys["formFlowDesign"] = "formFlowDesign"; })(TabKeys || (TabKeys = {})); var TABS = [{ label: '表单设计', key: TabKeys.formDesign }, { label: '流程设计', key: TabKeys.formFlowDesign }, { label: '表单设置', key: TabKeys.formSetting } // 自定义详情页需求:将表单发布移值表单设置中 // { label: '表单发布', key: TabKeys.formPublish }, ]; /** * 编辑器左侧组件资产列表 */ var InnerCompList = [{ id: 1, title: '常用组件', sort: 1, children: [{ label: '单行文本', compName: 'Input' }, { label: '下拉单选', compName: 'Select' }, { label: '下拉复选', compName: 'MultipleSelect' }, { label: '日期选择', compName: 'DatePicker' }, { label: '时间选择', compName: 'TimePicker' }, { label: '时间段选择', compName: 'RangePicker' }, { label: '多行文本', compName: 'TextArea' }, { label: '数字输入', compName: 'InputNumber' }, { label: '密码框', compName: 'Password' }, { label: '开关', compName: 'Switch' }, { label: '单选组', compName: 'Radio' }, { label: '复选组', compName: 'CheckboxGroup' }, { label: '手机', compName: 'InputPhone' }, { label: '邮箱', compName: 'InputMail' }, { label: '图片', compName: 'ImageShow' }, { label: '图片上传', compName: 'ImgUpload' }, { label: '视频上传', compName: 'VideoUpload' }, { label: '文件上传', compName: 'StdUpload' }, { label: '附件下载', compName: 'Attachments' }, { label: '评分', compName: 'Rate' }, { label: '分割线', compName: 'Divider' }] }, { id: 2, title: '关联组件', sort: 2, children: [{ label: '树选择', compName: 'TreeSelect' }, { label: '级联选择', compName: 'Cascader' }, { label: '关联数据', compName: 'DataLinkage' }, { label: '关联查询', compName: 'BindTable' }, { label: 'Api查询', compName: 'Api' }] }, { id: 3, title: '高级组件', sort: 3, children: [{ label: '定位', compName: 'Location' }, { label: '签名', compName: 'Autograph' }, { label: '成员', compName: 'AddMember' }, { label: '部门', compName: 'AddDepartment' }, { label: '子表单', compName: 'SubForm' }, { label: '附件校验', compName: 'CheckUpload' }, // { label: '文本识别', compName: 'TextRecognition' }, { label: '地址', compName: 'Address' }, { label: '图文展示', compName: 'Text' }, { label: '流水号', compName: 'SerialNumber' }] }, { id: 4, title: '布局组件', sort: 4, children: [{ label: '普通容器', compName: 'WFView' }, { label: '标签页', compName: 'WFTabs', compTypes: ['WFTabPane'] }] }, { id: 5, title: 'PC组件', sort: 5, // children: [{ label: '富文本', compName: 'QuillEditor' }], children: [{ label: '富文本', compName: 'RichTextEditor' }] }]; var iconActive = "data:image/svg+xml,%3Csvg%20width%3D%2217%22%20height%3D%226%22%20viewBox%3D%220%200%2017%206%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20id%3D%22Ellipse%20834%20%28Stroke%29%22%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M15.4823%200.262721C16.1003%200.71027%2016.2385%201.57404%2015.7909%202.19202C14.9384%203.36921%2013.8193%204.32793%2012.5252%204.98976C11.2312%205.6516%209.79884%205.99778%208.34535%205.99999C6.89185%206.0022%205.45847%205.66038%204.1624%205.00247C2.86633%204.34457%201.74436%203.38926%200.888232%202.21466C0.438807%201.59805%200.574336%200.733862%201.19094%200.284437C1.80755%20-0.164988%202.67174%20-0.0294594%203.12117%200.587149C3.72046%201.40937%204.50583%202.07808%205.41309%202.53862C6.32034%202.99915%207.3237%203.23842%208.34115%203.23688C9.35859%203.23533%2010.3612%202.99301%2011.2671%202.52972C12.1729%202.06643%2012.9563%201.39534%2013.5531%200.571298C14.0006%20-0.0466737%2014.8644%20-0.184828%2015.4823%200.262721Z%22%20fill%3D%22%232879FF%22%2F%3E%3C%2Fsvg%3E"; var styles = {"tabsWrap":"Tabs_tabsWrap__35rfH","activeTab":"Tabs_activeTab__lMqzu","activeLine":"Tabs_activeLine__2XNvL","tabItem":"Tabs_tabItem__21mSl"}; var Tabs = function Tabs(_ref) { var _ref$tabList = _ref.tabList, tabList = _ref$tabList === void 0 ? [] : _ref$tabList, activeKey = _ref.activeKey, onTabClick = _ref.onTabClick; return jsx("div", { className: classNames(_defineProperty(_defineProperty({}, styles.designHeaderTabs, activeKey === TabKeys.formDesign), styles.tabsWrap, true)), children: jsx(_Space, { size: "large", children: tabList.map(function (item) { return jsxs(_Button, { type: "text", className: classNames(styles.tabItem, _defineProperty({}, styles.activeTab, activeKey === item.key)), onClick: function onClick() { return onTabClick === null || onTabClick === void 0 ? void 0 : onTabClick(item); }, children: [item.label, activeKey === item.key && jsx("img", { className: styles.activeLine, alt: "", src: iconActive })] }, item.key); }) }) }); }; var styles$1 = {"search":"index_search__28TQ-","select":"index_select__bVhXn","busiCompList":"index_busiCompList__2riVs","list":"index_list__3UG7E","item":"index_item__dkpQe","cell":"index_cell__2owWA","ico":"index_ico__8omc9","tit":"index_tit__3KxJy","cont":"index_cont__2IPa3"}; /* eslint-disable */ var IconBusinessCompTab = function IconBusinessCompTab() { return jsx("svg", { viewBox: "0 0 1024 1024", version: "1.1", xmlns: "http://www.w3.org/2000/svg", "p-id": "9329", width: "20", height: "20", children: jsx("path", { d: "M844.8 102.4A76.8 76.8 0 0 1 921.6 179.2v665.6a76.8 76.8 0 0 1-76.8 76.8h-665.6A76.8 76.8 0 0 1 102.4 844.8v-665.6A76.8 76.8 0 0 1 179.2 102.4h665.6z m0 58.368h-665.6a18.432 18.432 0 0 0-18.0736 14.6944L160.768 179.2v665.6c0 8.9088 6.2976 16.384 14.694