Jelajahi Sumber

1. 清理旧版本的 form generator
2. 接入表单详情

YunaiV 3 tahun lalu
induk
melakukan
f45224f224
29 mengubah file dengan 180 tambahan dan 2443 penghapusan
  1. 0 1
      yudao-admin-ui/src/utils/generator/README.md
  2. 0 629
      yudao-admin-ui/src/utils/generator/config.js
  3. 0 18
      yudao-admin-ui/src/utils/generator/css.js
  4. 0 37
      yudao-admin-ui/src/utils/generator/drawingDefalut.js
  5. 0 399
      yudao-admin-ui/src/utils/generator/html.js
  6. 0 271
      yudao-admin-ui/src/utils/generator/js.js
  7. 0 126
      yudao-admin-ui/src/utils/generator/render.js
  8. 0 16
      yudao-admin-ui/src/utils/generator/ruleTrigger.js
  9. 0 0
      yudao-admin-ui/src/utils/icon.json
  10. 0 188
      yudao-admin-ui/src/utils/parser/Parser.vue
  11. 0 19
      yudao-admin-ui/src/utils/parser/README.md
  12. 0 324
      yudao-admin-ui/src/utils/parser/example/Index.vue
  13. 0 3
      yudao-admin-ui/src/utils/parser/index.js
  14. 0 25
      yudao-admin-ui/src/utils/parser/package.json
  15. 0 1
      yudao-admin-ui/src/utils/render/README.md
  16. 0 19
      yudao-admin-ui/src/utils/render/package.json
  17. 0 122
      yudao-admin-ui/src/utils/render/render.js
  18. 0 5
      yudao-admin-ui/src/utils/render/slots/el-button.js
  19. 0 13
      yudao-admin-ui/src/utils/render/slots/el-checkbox-group.js
  20. 0 8
      yudao-admin-ui/src/utils/render/slots/el-input.js
  21. 0 13
      yudao-admin-ui/src/utils/render/slots/el-radio-group.js
  22. 0 9
      yudao-admin-ui/src/utils/render/slots/el-select.js
  23. 0 17
      yudao-admin-ui/src/utils/render/slots/el-upload.js
  24. 1 1
      yudao-admin-ui/src/views/bpm/form/formEditor.vue
  25. 173 173
      yudao-admin-ui/src/views/bpm/form/index.vue
  26. 3 3
      yudao-admin-ui/src/views/tool/build/FormDrawer.vue
  27. 1 1
      yudao-admin-ui/src/views/tool/build/IconsDialog.vue
  28. 1 1
      yudao-admin-ui/src/views/tool/build/RightPanel.vue
  29. 1 1
      yudao-admin-ui/src/views/tool/build/index.vue

+ 0 - 1
yudao-admin-ui/src/utils/generator/README.md

@@ -1 +0,0 @@
-【add by 芋道源码】来自 https://github.com/JakHuang/form-generator/tree/dev/src/components/generator 目录

+ 0 - 629
yudao-admin-ui/src/utils/generator/config.js

@@ -1,629 +0,0 @@
-// 表单属性【右面板】
-export const formConf = {
-  formRef: 'elForm',
-  formModel: 'formData',
-  size: 'medium',
-  labelPosition: 'right',
-  labelWidth: 100,
-  formRules: 'rules',
-  gutter: 15,
-  disabled: false,
-  span: 24,
-  formBtns: true
-}
-
-// 输入型组件 【左面板】
-export const inputComponents = [
-  {
-    // 组件的自定义配置
-    __config__: {
-      label: '单行文本',
-      labelWidth: null,
-      showLabel: true,
-      changeTag: true,
-      tag: 'el-input',
-      tagIcon: 'input',
-      defaultValue: undefined,
-      required: true,
-      layout: 'colFormItem',
-      span: 24,
-      document: 'https://element.eleme.cn/#/zh-CN/component/input',
-      // 正则校验规则
-      regList: []
-    },
-    // 组件的插槽属性
-    __slot__: {
-      prepend: '',
-      append: ''
-    },
-    // 其余的为可直接写在组件标签上的属性
-    placeholder: '请输入',
-    style: {width: '100%'},
-    clearable: true,
-    'prefix-icon': '',
-    'suffix-icon': '',
-    maxlength: null,
-    'show-word-limit': false,
-    readonly: false,
-    disabled: false
-  },
-  {
-    __config__: {
-      label: '多行文本',
-      labelWidth: null,
-      showLabel: true,
-      tag: 'el-input',
-      tagIcon: 'textarea',
-      defaultValue: undefined,
-      required: true,
-      layout: 'colFormItem',
-      span: 24,
-      regList: [],
-      changeTag: true,
-      document: 'https://element.eleme.cn/#/zh-CN/component/input'
-    },
-    type: 'textarea',
-    placeholder: '请输入',
-    autosize: {
-      minRows: 4,
-      maxRows: 4
-    },
-    style: {width: '100%'},
-    maxlength: null,
-    'show-word-limit': false,
-    readonly: false,
-    disabled: false
-  },
-  {
-    __config__: {
-      label: '密码',
-      showLabel: true,
-      labelWidth: null,
-      changeTag: true,
-      tag: 'el-input',
-      tagIcon: 'password',
-      defaultValue: undefined,
-      layout: 'colFormItem',
-      span: 24,
-      required: true,
-      regList: [],
-      document: 'https://element.eleme.cn/#/zh-CN/component/input'
-    },
-    __slot__: {
-      prepend: '',
-      append: ''
-    },
-    placeholder: '请输入',
-    'show-password': true,
-    style: {width: '100%'},
-    clearable: true,
-    'prefix-icon': '',
-    'suffix-icon': '',
-    maxlength: null,
-    'show-word-limit': false,
-    readonly: false,
-    disabled: false
-  },
-  {
-    __config__: {
-      label: '计数器',
-      showLabel: true,
-      changeTag: true,
-      labelWidth: null,
-      tag: 'el-input-number',
-      tagIcon: 'number',
-      defaultValue: undefined,
-      span: 24,
-      layout: 'colFormItem',
-      required: true,
-      regList: [],
-      document: 'https://element.eleme.cn/#/zh-CN/component/input-number'
-    },
-    placeholder: '',
-    min: undefined,
-    max: undefined,
-    step: 1,
-    'step-strictly': false,
-    precision: undefined,
-    'controls-position': '',
-    disabled: false
-  },
-  {
-    __config__: {
-      label: '编辑器',
-      showLabel: true,
-      changeTag: true,
-      labelWidth: null,
-      tag: 'tinymce',
-      tagIcon: 'rich-text',
-      defaultValue: null,
-      span: 24,
-      layout: 'colFormItem',
-      required: true,
-      regList: [],
-      document: 'http://tinymce.ax-z.cn'
-    },
-    placeholder: '请输入',
-    height: 300, // 编辑器高度
-    branding: false // 隐藏右下角品牌烙印
-  }
-]
-
-// 选择型组件 【左面板】
-export const selectComponents = [
-  {
-    __config__: {
-      label: '下拉选择',
-      showLabel: true,
-      labelWidth: null,
-      tag: 'el-select',
-      tagIcon: 'select',
-      layout: 'colFormItem',
-      span: 24,
-      required: true,
-      regList: [],
-      changeTag: true,
-      document: 'https://element.eleme.cn/#/zh-CN/component/select'
-    },
-    __slot__: {
-      options: [{
-        label: '选项一',
-        value: 1
-      }, {
-        label: '选项二',
-        value: 2
-      }]
-    },
-    placeholder: '请选择',
-    style: {width: '100%'},
-    clearable: true,
-    disabled: false,
-    filterable: false,
-    multiple: false
-  },
-  {
-    __config__: {
-      label: '级联选择',
-      url: 'https://www.fastmock.site/mock/f8d7a54fb1e60561e2f720d5a810009d/fg/cascaderList',
-      method: 'get',
-      dataPath: 'list',
-      dataConsumer: 'options',
-      showLabel: true,
-      labelWidth: null,
-      tag: 'el-cascader',
-      tagIcon: 'cascader',
-      layout: 'colFormItem',
-      defaultValue: [],
-      dataType: 'dynamic',
-      span: 24,
-      required: true,
-      regList: [],
-      changeTag: true,
-      document: 'https://element.eleme.cn/#/zh-CN/component/cascader'
-    },
-    options: [{
-      id: 1,
-      value: 1,
-      label: '选项1',
-      children: [{
-        id: 2,
-        value: 2,
-        label: '选项1-1'
-      }]
-    }],
-    placeholder: '请选择',
-    style: {width: '100%'},
-    props: {
-      props: {
-        multiple: false,
-        label: 'label',
-        value: 'value',
-        children: 'children'
-      }
-    },
-    'show-all-levels': true,
-    disabled: false,
-    clearable: true,
-    filterable: false,
-    separator: '/'
-  },
-  {
-    __config__: {
-      label: '单选框组',
-      labelWidth: null,
-      showLabel: true,
-      tag: 'el-radio-group',
-      tagIcon: 'radio',
-      changeTag: true,
-      defaultValue: undefined,
-      layout: 'colFormItem',
-      span: 24,
-      optionType: 'default',
-      regList: [],
-      required: true,
-      border: false,
-      document: 'https://element.eleme.cn/#/zh-CN/component/radio'
-    },
-    __slot__: {
-      options: [{
-        label: '选项一',
-        value: 1
-      }, {
-        label: '选项二',
-        value: 2
-      }]
-    },
-    style: {},
-    size: 'medium',
-    disabled: false
-  },
-  {
-    __config__: {
-      label: '多选框组',
-      tag: 'el-checkbox-group',
-      tagIcon: 'checkbox',
-      defaultValue: [],
-      span: 24,
-      showLabel: true,
-      labelWidth: null,
-      layout: 'colFormItem',
-      optionType: 'default',
-      required: true,
-      regList: [],
-      changeTag: true,
-      border: false,
-      document: 'https://element.eleme.cn/#/zh-CN/component/checkbox'
-    },
-    __slot__: {
-      options: [{
-        label: '选项一',
-        value: 1
-      }, {
-        label: '选项二',
-        value: 2
-      }]
-    },
-    style: {},
-    size: 'medium',
-    min: null,
-    max: null,
-    disabled: false
-  },
-  {
-    __config__: {
-      label: '开关',
-      tag: 'el-switch',
-      tagIcon: 'switch',
-      defaultValue: false,
-      span: 24,
-      showLabel: true,
-      labelWidth: null,
-      layout: 'colFormItem',
-      required: true,
-      regList: [],
-      changeTag: true,
-      document: 'https://element.eleme.cn/#/zh-CN/component/switch'
-    },
-    style: {},
-    disabled: false,
-    'active-text': '',
-    'inactive-text': '',
-    'active-color': null,
-    'inactive-color': null,
-    'active-value': true,
-    'inactive-value': false
-  },
-  {
-    __config__: {
-      label: '滑块',
-      tag: 'el-slider',
-      tagIcon: 'slider',
-      defaultValue: null,
-      span: 24,
-      showLabel: true,
-      layout: 'colFormItem',
-      labelWidth: null,
-      required: true,
-      regList: [],
-      changeTag: true,
-      document: 'https://element.eleme.cn/#/zh-CN/component/slider'
-    },
-    disabled: false,
-    min: 0,
-    max: 100,
-    step: 1,
-    'show-stops': false,
-    range: false
-  },
-  {
-    __config__: {
-      label: '时间选择',
-      tag: 'el-time-picker',
-      tagIcon: 'time',
-      defaultValue: null,
-      span: 24,
-      showLabel: true,
-      layout: 'colFormItem',
-      labelWidth: null,
-      required: true,
-      regList: [],
-      changeTag: true,
-      document: 'https://element.eleme.cn/#/zh-CN/component/time-picker'
-    },
-    placeholder: '请选择',
-    style: {width: '100%'},
-    disabled: false,
-    clearable: true,
-    'picker-options': {
-      selectableRange: '00:00:00-23:59:59'
-    },
-    format: 'HH:mm:ss',
-    'value-format': 'HH:mm:ss'
-  },
-  {
-    __config__: {
-      label: '时间范围',
-      tag: 'el-time-picker',
-      tagIcon: 'time-range',
-      span: 24,
-      showLabel: true,
-      labelWidth: null,
-      layout: 'colFormItem',
-      defaultValue: null,
-      required: true,
-      regList: [],
-      changeTag: true,
-      document: 'https://element.eleme.cn/#/zh-CN/component/time-picker'
-    },
-    style: {width: '100%'},
-    disabled: false,
-    clearable: true,
-    'is-range': true,
-    'range-separator': '至',
-    'start-placeholder': '开始时间',
-    'end-placeholder': '结束时间',
-    format: 'HH:mm:ss',
-    'value-format': 'HH:mm:ss'
-  },
-  {
-    __config__: {
-      label: '日期选择',
-      tag: 'el-date-picker',
-      tagIcon: 'date',
-      defaultValue: null,
-      showLabel: true,
-      labelWidth: null,
-      span: 24,
-      layout: 'colFormItem',
-      required: true,
-      regList: [],
-      changeTag: true,
-      document: 'https://element.eleme.cn/#/zh-CN/component/date-picker'
-    },
-    placeholder: '请选择',
-    type: 'date',
-    style: {width: '100%'},
-    disabled: false,
-    clearable: true,
-    format: 'yyyy-MM-dd',
-    'value-format': 'yyyy-MM-dd',
-    readonly: false
-  },
-  {
-    __config__: {
-      label: '日期范围',
-      tag: 'el-date-picker',
-      tagIcon: 'date-range',
-      defaultValue: null,
-      span: 24,
-      showLabel: true,
-      labelWidth: null,
-      required: true,
-      layout: 'colFormItem',
-      regList: [],
-      changeTag: true,
-      document: 'https://element.eleme.cn/#/zh-CN/component/date-picker'
-    },
-    style: {width: '100%'},
-    type: 'daterange',
-    'range-separator': '至',
-    'start-placeholder': '开始日期',
-    'end-placeholder': '结束日期',
-    disabled: false,
-    clearable: true,
-    format: 'yyyy-MM-dd',
-    'value-format': 'yyyy-MM-dd',
-    readonly: false
-  },
-  {
-    __config__: {
-      label: '评分',
-      tag: 'el-rate',
-      tagIcon: 'rate',
-      defaultValue: 0,
-      span: 24,
-      showLabel: true,
-      labelWidth: null,
-      layout: 'colFormItem',
-      required: true,
-      regList: [],
-      changeTag: true,
-      document: 'https://element.eleme.cn/#/zh-CN/component/rate'
-    },
-    style: {},
-    max: 5,
-    'allow-half': false,
-    'show-text': false,
-    'show-score': false,
-    disabled: false
-  },
-  {
-    __config__: {
-      label: '颜色选择',
-      tag: 'el-color-picker',
-      tagIcon: 'color',
-      span: 24,
-      defaultValue: null,
-      showLabel: true,
-      labelWidth: null,
-      layout: 'colFormItem',
-      required: true,
-      regList: [],
-      changeTag: true,
-      document: 'https://element.eleme.cn/#/zh-CN/component/color-picker'
-    },
-    'show-alpha': false,
-    'color-format': '',
-    disabled: false,
-    size: 'medium'
-  },
-  {
-    __config__: {
-      label: '上传',
-      tag: 'el-upload',
-      tagIcon: 'upload',
-      layout: 'colFormItem',
-      defaultValue: null,
-      showLabel: true,
-      labelWidth: null,
-      required: true,
-      span: 24,
-      showTip: false,
-      buttonText: '点击上传',
-      regList: [],
-      changeTag: true,
-      fileSize: 2,
-      sizeUnit: 'MB',
-      document: 'https://element.eleme.cn/#/zh-CN/component/upload'
-    },
-    __slot__: {
-      'list-type': true
-    },
-    action: 'https://jsonplaceholder.typicode.com/posts/',
-    disabled: false,
-    accept: '',
-    name: 'file',
-    'auto-upload': true,
-    'list-type': 'text',
-    multiple: false
-  }
-]
-
-// 布局型组件 【左面板】
-export const layoutComponents = [
-  {
-    __config__: {
-      layout: 'rowFormItem',
-      tagIcon: 'row',
-      label: '行容器',
-      layoutTree: true,
-      document: 'https://element.eleme.cn/#/zh-CN/component/layout#row-attributes'
-    },
-    type: 'default',
-    justify: 'start',
-    align: 'top'
-  },
-  {
-    __config__: {
-      label: '按钮',
-      showLabel: true,
-      changeTag: true,
-      labelWidth: null,
-      tag: 'el-button',
-      tagIcon: 'button',
-      span: 24,
-      layout: 'colFormItem',
-      document: 'https://element.eleme.cn/#/zh-CN/component/button'
-    },
-    __slot__: {
-      default: '主要按钮'
-    },
-    type: 'primary',
-    icon: 'el-icon-search',
-    round: false,
-    size: 'medium',
-    plain: false,
-    circle: false,
-    disabled: false
-  },
-  {
-    __config__: {
-      layout: 'colFormItem',
-      tagIcon: 'table',
-      tag: 'el-table',
-      document: 'https://element.eleme.cn/#/zh-CN/component/table',
-      span: 24,
-      formId: 101,
-      renderKey: 1595761764203,
-      componentName: 'row101',
-      showLabel: true,
-      changeTag: true,
-      labelWidth: null,
-      label: '表格[开发中]',
-      dataType: 'dynamic',
-      method: 'get',
-      dataPath: 'list',
-      dataConsumer: 'data',
-      url: 'https://www.fastmock.site/mock/f8d7a54fb1e60561e2f720d5a810009d/fg/tableData',
-      children: [{
-        __config__: {
-          layout: 'raw',
-          tag: 'el-table-column',
-          renderKey: 15957617660153
-        },
-        prop: 'date',
-        label: '日期'
-      }, {
-        __config__: {
-          layout: 'raw',
-          tag: 'el-table-column',
-          renderKey: 15957617660152
-        },
-        prop: 'address',
-        label: '地址'
-      }, {
-        __config__: {
-          layout: 'raw',
-          tag: 'el-table-column',
-          renderKey: 15957617660151
-        },
-        prop: 'name',
-        label: '名称'
-      }, {
-        __config__: {
-          layout: 'raw',
-          tag: 'el-table-column',
-          renderKey: 1595774496335,
-          children: [
-            {
-              __config__: {
-                label: '按钮',
-                tag: 'el-button',
-                tagIcon: 'button',
-                layout: 'raw',
-                renderKey: 1595779809901
-              },
-              __slot__: {
-                default: '主要按钮'
-              },
-              type: 'primary',
-              icon: 'el-icon-search',
-              round: false,
-              size: 'medium'
-            }
-          ]
-        },
-        label: '操作'
-      }]
-    },
-    data: [],
-    directives: [{
-      name: 'loading',
-      value: true
-    }],
-    border: true,
-    type: 'default',
-    justify: 'start',
-    align: 'top'
-  }
-]

+ 0 - 18
yudao-admin-ui/src/utils/generator/css.js

@@ -1,18 +0,0 @@
-const styles = {
-  'el-rate': '.el-rate{display: inline-block; vertical-align: text-top;}',
-  'el-upload': '.el-upload__tip{line-height: 1.2;}'
-}
-
-function addCss(cssList, el) {
-  const css = styles[el.tag]
-  css && cssList.indexOf(css) === -1 && cssList.push(css)
-  if (el.children) {
-    el.children.forEach(el2 => addCss(cssList, el2))
-  }
-}
-
-export function makeUpCss(conf) {
-  const cssList = []
-  conf.fields.forEach(el => addCss(cssList, el))
-  return cssList.join('\n')
-}

+ 0 - 37
yudao-admin-ui/src/utils/generator/drawingDefalut.js

@@ -1,37 +0,0 @@
-export default [
-  {
-    __config__: {
-      label: '单行文本',
-      labelWidth: null,
-      showLabel: true,
-      changeTag: true,
-      tag: 'el-input',
-      tagIcon: 'input',
-      defaultValue: undefined,
-      required: true,
-      layout: 'colFormItem',
-      span: 24,
-      document: 'https://element.eleme.cn/#/zh-CN/component/input',
-      // 正则校验规则
-      regList: [{
-        pattern: '/^1(3|4|5|7|8|9)\\d{9}$/',
-        message: '手机号格式错误'
-      }]
-    },
-    // 组件的插槽属性
-    __slot__: {
-      prepend: '',
-      append: ''
-    },
-    __vModel__: 'mobile',
-    placeholder: '请输入手机号',
-    style: { width: '100%' },
-    clearable: true,
-    'prefix-icon': 'el-icon-mobile',
-    'suffix-icon': '',
-    maxlength: 11,
-    'show-word-limit': true,
-    readonly: false,
-    disabled: false
-  }
-]

+ 0 - 399
yudao-admin-ui/src/utils/generator/html.js

@@ -1,399 +0,0 @@
-/* eslint-disable max-len */
-import ruleTrigger from './ruleTrigger'
-
-let confGlobal
-let someSpanIsNot24
-
-export function dialogWrapper(str) {
-  return `<el-dialog v-bind="$attrs" v-on="$listeners" @open="onOpen" @close="onClose" title="Dialog Titile">
-    ${str}
-    <div slot="footer">
-      <el-button @click="close">取消</el-button>
-      <el-button type="primary" @click="handelConfirm">确定</el-button>
-    </div>
-  </el-dialog>`
-}
-
-export function vueTemplate(str) {
-  return `<template>
-    <div>
-      ${str}
-    </div>
-  </template>`
-}
-
-export function vueScript(str) {
-  return `<script>
-    ${str}
-  </script>`
-}
-
-export function cssStyle(cssStr) {
-  return `<style>
-    ${cssStr}
-  </style>`
-}
-
-function buildFormTemplate(scheme, child, type) {
-  let labelPosition = ''
-  if (scheme.labelPosition !== 'right') {
-    labelPosition = `label-position="${scheme.labelPosition}"`
-  }
-  const disabled = scheme.disabled ? `:disabled="${scheme.disabled}"` : ''
-  let str = `<el-form ref="${scheme.formRef}" :model="${scheme.formModel}" :rules="${scheme.formRules}" size="${scheme.size}" ${disabled} label-width="${scheme.labelWidth}px" ${labelPosition}>
-      ${child}
-      ${buildFromBtns(scheme, type)}
-    </el-form>`
-  if (someSpanIsNot24) {
-    str = `<el-row :gutter="${scheme.gutter}">
-        ${str}
-      </el-row>`
-  }
-  return str
-}
-
-function buildFromBtns(scheme, type) {
-  let str = ''
-  if (scheme.formBtns && type === 'file') {
-    str = `<el-form-item size="large">
-          <el-button type="primary" @click="submitForm">提交</el-button>
-          <el-button @click="resetForm">重置</el-button>
-        </el-form-item>`
-    if (someSpanIsNot24) {
-      str = `<el-col :span="24">
-          ${str}
-        </el-col>`
-    }
-  }
-  return str
-}
-
-// span不为24的用el-col包裹
-function colWrapper(scheme, str) {
-  if (someSpanIsNot24 || scheme.__config__.span !== 24) {
-    return `<el-col :span="${scheme.__config__.span}">
-      ${str}
-    </el-col>`
-  }
-  return str
-}
-
-const layouts = {
-  colFormItem(scheme) {
-    const config = scheme.__config__
-    let labelWidth = ''
-    let label = `label="${config.label}"`
-    if (config.labelWidth && config.labelWidth !== confGlobal.labelWidth) {
-      labelWidth = `label-width="${config.labelWidth}px"`
-    }
-    if (config.showLabel === false) {
-      labelWidth = 'label-width="0"'
-      label = ''
-    }
-    const required = !ruleTrigger[config.tag] && config.required ? 'required' : ''
-    const tagDom = tags[config.tag] ? tags[config.tag](scheme) : null
-    let str = `<el-form-item ${labelWidth} ${label} prop="${scheme.__vModel__}" ${required}>
-        ${tagDom}
-      </el-form-item>`
-    str = colWrapper(scheme, str)
-    return str
-  },
-  rowFormItem(scheme) {
-    const config = scheme.__config__
-    const type = scheme.type === 'default' ? '' : `type="${scheme.type}"`
-    const justify = scheme.type === 'default' ? '' : `justify="${scheme.justify}"`
-    const align = scheme.type === 'default' ? '' : `align="${scheme.align}"`
-    const gutter = scheme.gutter ? `:gutter="${scheme.gutter}"` : ''
-    const children = config.children.map(el => layouts[el.__config__.layout](el))
-    let str = `<el-row ${type} ${justify} ${align} ${gutter}>
-      ${children.join('\n')}
-    </el-row>`
-    str = colWrapper(scheme, str)
-    return str
-  }
-}
-
-const tags = {
-  'el-button': el => {
-    const {
-      tag, disabled
-    } = attrBuilder(el)
-    const type = el.type ? `type="${el.type}"` : ''
-    const icon = el.icon ? `icon="${el.icon}"` : ''
-    const round = el.round ? 'round' : ''
-    const size = el.size ? `size="${el.size}"` : ''
-    const plain = el.plain ? 'plain' : ''
-    const circle = el.circle ? 'circle' : ''
-    let child = buildElButtonChild(el)
-
-    if (child) child = `\n${child}\n` // 换行
-    return `<${tag} ${type} ${icon} ${round} ${size} ${plain} ${disabled} ${circle}>${child}</${tag}>`
-  },
-  'el-input': el => {
-    const {
-      tag, disabled, vModel, clearable, placeholder, width
-    } = attrBuilder(el)
-    const maxlength = el.maxlength ? `:maxlength="${el.maxlength}"` : ''
-    const showWordLimit = el['show-word-limit'] ? 'show-word-limit' : ''
-    const readonly = el.readonly ? 'readonly' : ''
-    const prefixIcon = el['prefix-icon'] ? `prefix-icon='${el['prefix-icon']}'` : ''
-    const suffixIcon = el['suffix-icon'] ? `suffix-icon='${el['suffix-icon']}'` : ''
-    const showPassword = el['show-password'] ? 'show-password' : ''
-    const type = el.type ? `type="${el.type}"` : ''
-    const autosize = el.autosize && el.autosize.minRows
-      ? `:autosize="{minRows: ${el.autosize.minRows}, maxRows: ${el.autosize.maxRows}}"`
-      : ''
-    let child = buildElInputChild(el)
-
-    if (child) child = `\n${child}\n` // 换行
-    return `<${tag} ${vModel} ${type} ${placeholder} ${maxlength} ${showWordLimit} ${readonly} ${disabled} ${clearable} ${prefixIcon} ${suffixIcon} ${showPassword} ${autosize} ${width}>${child}</${tag}>`
-  },
-  'el-input-number': el => {
-    const {
-      tag, disabled, vModel, placeholder
-    } = attrBuilder(el)
-    const controlsPosition = el['controls-position'] ? `controls-position=${el['controls-position']}` : ''
-    const min = el.min ? `:min='${el.min}'` : ''
-    const max = el.max ? `:max='${el.max}'` : ''
-    const step = el.step ? `:step='${el.step}'` : ''
-    const stepStrictly = el['step-strictly'] ? 'step-strictly' : ''
-    const precision = el.precision ? `:precision='${el.precision}'` : ''
-
-    return `<${tag} ${vModel} ${placeholder} ${step} ${stepStrictly} ${precision} ${controlsPosition} ${min} ${max} ${disabled}></${tag}>`
-  },
-  'el-select': el => {
-    const {
-      tag, disabled, vModel, clearable, placeholder, width
-    } = attrBuilder(el)
-    const filterable = el.filterable ? 'filterable' : ''
-    const multiple = el.multiple ? 'multiple' : ''
-    let child = buildElSelectChild(el)
-
-    if (child) child = `\n${child}\n` // 换行
-    return `<${tag} ${vModel} ${placeholder} ${disabled} ${multiple} ${filterable} ${clearable} ${width}>${child}</${tag}>`
-  },
-  'el-radio-group': el => {
-    const { tag, disabled, vModel } = attrBuilder(el)
-    const size = `size="${el.size}"`
-    let child = buildElRadioGroupChild(el)
-
-    if (child) child = `\n${child}\n` // 换行
-    return `<${tag} ${vModel} ${size} ${disabled}>${child}</${tag}>`
-  },
-  'el-checkbox-group': el => {
-    const { tag, disabled, vModel } = attrBuilder(el)
-    const size = `size="${el.size}"`
-    const min = el.min ? `:min="${el.min}"` : ''
-    const max = el.max ? `:max="${el.max}"` : ''
-    let child = buildElCheckboxGroupChild(el)
-
-    if (child) child = `\n${child}\n` // 换行
-    return `<${tag} ${vModel} ${min} ${max} ${size} ${disabled}>${child}</${tag}>`
-  },
-  'el-switch': el => {
-    const { tag, disabled, vModel } = attrBuilder(el)
-    const activeText = el['active-text'] ? `active-text="${el['active-text']}"` : ''
-    const inactiveText = el['inactive-text'] ? `inactive-text="${el['inactive-text']}"` : ''
-    const activeColor = el['active-color'] ? `active-color="${el['active-color']}"` : ''
-    const inactiveColor = el['inactive-color'] ? `inactive-color="${el['inactive-color']}"` : ''
-    const activeValue = el['active-value'] !== true ? `:active-value='${JSON.stringify(el['active-value'])}'` : ''
-    const inactiveValue = el['inactive-value'] !== false ? `:inactive-value='${JSON.stringify(el['inactive-value'])}'` : ''
-
-    return `<${tag} ${vModel} ${activeText} ${inactiveText} ${activeColor} ${inactiveColor} ${activeValue} ${inactiveValue} ${disabled}></${tag}>`
-  },
-  'el-cascader': el => {
-    const {
-      tag, disabled, vModel, clearable, placeholder, width
-    } = attrBuilder(el)
-    const options = el.options ? `:options="${el.__vModel__}Options"` : ''
-    const props = el.props ? `:props="${el.__vModel__}Props"` : ''
-    const showAllLevels = el['show-all-levels'] ? '' : ':show-all-levels="false"'
-    const filterable = el.filterable ? 'filterable' : ''
-    const separator = el.separator === '/' ? '' : `separator="${el.separator}"`
-
-    return `<${tag} ${vModel} ${options} ${props} ${width} ${showAllLevels} ${placeholder} ${separator} ${filterable} ${clearable} ${disabled}></${tag}>`
-  },
-  'el-slider': el => {
-    const { tag, disabled, vModel } = attrBuilder(el)
-    const min = el.min ? `:min='${el.min}'` : ''
-    const max = el.max ? `:max='${el.max}'` : ''
-    const step = el.step ? `:step='${el.step}'` : ''
-    const range = el.range ? 'range' : ''
-    const showStops = el['show-stops'] ? `:show-stops="${el['show-stops']}"` : ''
-
-    return `<${tag} ${min} ${max} ${step} ${vModel} ${range} ${showStops} ${disabled}></${tag}>`
-  },
-  'el-time-picker': el => {
-    const {
-      tag, disabled, vModel, clearable, placeholder, width
-    } = attrBuilder(el)
-    const startPlaceholder = el['start-placeholder'] ? `start-placeholder="${el['start-placeholder']}"` : ''
-    const endPlaceholder = el['end-placeholder'] ? `end-placeholder="${el['end-placeholder']}"` : ''
-    const rangeSeparator = el['range-separator'] ? `range-separator="${el['range-separator']}"` : ''
-    const isRange = el['is-range'] ? 'is-range' : ''
-    const format = el.format ? `format="${el.format}"` : ''
-    const valueFormat = el['value-format'] ? `value-format="${el['value-format']}"` : ''
-    const pickerOptions = el['picker-options'] ? `:picker-options='${JSON.stringify(el['picker-options'])}'` : ''
-
-    return `<${tag} ${vModel} ${isRange} ${format} ${valueFormat} ${pickerOptions} ${width} ${placeholder} ${startPlaceholder} ${endPlaceholder} ${rangeSeparator} ${clearable} ${disabled}></${tag}>`
-  },
-  'el-date-picker': el => {
-    const {
-      tag, disabled, vModel, clearable, placeholder, width
-    } = attrBuilder(el)
-    const startPlaceholder = el['start-placeholder'] ? `start-placeholder="${el['start-placeholder']}"` : ''
-    const endPlaceholder = el['end-placeholder'] ? `end-placeholder="${el['end-placeholder']}"` : ''
-    const rangeSeparator = el['range-separator'] ? `range-separator="${el['range-separator']}"` : ''
-    const format = el.format ? `format="${el.format}"` : ''
-    const valueFormat = el['value-format'] ? `value-format="${el['value-format']}"` : ''
-    const type = el.type === 'date' ? '' : `type="${el.type}"`
-    const readonly = el.readonly ? 'readonly' : ''
-
-    return `<${tag} ${type} ${vModel} ${format} ${valueFormat} ${width} ${placeholder} ${startPlaceholder} ${endPlaceholder} ${rangeSeparator} ${clearable} ${readonly} ${disabled}></${tag}>`
-  },
-  'el-rate': el => {
-    const { tag, disabled, vModel } = attrBuilder(el)
-    const max = el.max ? `:max='${el.max}'` : ''
-    const allowHalf = el['allow-half'] ? 'allow-half' : ''
-    const showText = el['show-text'] ? 'show-text' : ''
-    const showScore = el['show-score'] ? 'show-score' : ''
-
-    return `<${tag} ${vModel} ${max} ${allowHalf} ${showText} ${showScore} ${disabled}></${tag}>`
-  },
-  'el-color-picker': el => {
-    const { tag, disabled, vModel } = attrBuilder(el)
-    const size = `size="${el.size}"`
-    const showAlpha = el['show-alpha'] ? 'show-alpha' : ''
-    const colorFormat = el['color-format'] ? `color-format="${el['color-format']}"` : ''
-
-    return `<${tag} ${vModel} ${size} ${showAlpha} ${colorFormat} ${disabled}></${tag}>`
-  },
-  'el-upload': el => {
-    const { tag } = el.__config__
-    const disabled = el.disabled ? ':disabled=\'true\'' : ''
-    const action = el.action ? `:action="${el.__vModel__}Action"` : ''
-    const multiple = el.multiple ? 'multiple' : ''
-    const listType = el['list-type'] !== 'text' ? `list-type="${el['list-type']}"` : ''
-    const accept = el.accept ? `accept="${el.accept}"` : ''
-    const name = el.name !== 'file' ? `name="${el.name}"` : ''
-    const autoUpload = el['auto-upload'] === false ? ':auto-upload="false"' : ''
-    const beforeUpload = `:before-upload="${el.__vModel__}BeforeUpload"`
-    const fileList = `:file-list="${el.__vModel__}fileList"`
-    const ref = `ref="${el.__vModel__}"`
-    let child = buildElUploadChild(el)
-
-    if (child) child = `\n${child}\n` // 换行
-    return `<${tag} ${ref} ${fileList} ${action} ${autoUpload} ${multiple} ${beforeUpload} ${listType} ${accept} ${name} ${disabled}>${child}</${tag}>`
-  },
-  tinymce: el => {
-    const { tag, vModel, placeholder } = attrBuilder(el)
-    const height = el.height ? `:height="${el.height}"` : ''
-    const branding = el.branding ? `:branding="${el.branding}"` : ''
-    return `<${tag} ${vModel} ${placeholder} ${height} ${branding}></${tag}>`
-  }
-}
-
-function attrBuilder(el) {
-  return {
-    tag: el.__config__.tag,
-    vModel: `v-model="${confGlobal.formModel}.${el.__vModel__}"`,
-    clearable: el.clearable ? 'clearable' : '',
-    placeholder: el.placeholder ? `placeholder="${el.placeholder}"` : '',
-    width: el.style && el.style.width ? ':style="{width: \'100%\'}"' : '',
-    disabled: el.disabled ? ':disabled=\'true\'' : ''
-  }
-}
-
-// el-buttin 子级
-function buildElButtonChild(scheme) {
-  const children = []
-  const slot = scheme.__slot__ || {}
-  if (slot.default) {
-    children.push(slot.default)
-  }
-  return children.join('\n')
-}
-
-// el-input 子级
-function buildElInputChild(scheme) {
-  const children = []
-  const slot = scheme.__slot__
-  if (slot && slot.prepend) {
-    children.push(`<template slot="prepend">${slot.prepend}</template>`)
-  }
-  if (slot && slot.append) {
-    children.push(`<template slot="append">${slot.append}</template>`)
-  }
-  return children.join('\n')
-}
-
-// el-select 子级
-function buildElSelectChild(scheme) {
-  const children = []
-  const slot = scheme.__slot__
-  if (slot && slot.options && slot.options.length) {
-    children.push(`<el-option v-for="(item, index) in ${scheme.__vModel__}Options" :key="index" :label="item.label" :value="item.value" :disabled="item.disabled"></el-option>`)
-  }
-  return children.join('\n')
-}
-
-// el-radio-group 子级
-function buildElRadioGroupChild(scheme) {
-  const children = []
-  const slot = scheme.__slot__
-  const config = scheme.__config__
-  if (slot && slot.options && slot.options.length) {
-    const tag = config.optionType === 'button' ? 'el-radio-button' : 'el-radio'
-    const border = config.border ? 'border' : ''
-    children.push(`<${tag} v-for="(item, index) in ${scheme.__vModel__}Options" :key="index" :label="item.value" :disabled="item.disabled" ${border}>{{item.label}}</${tag}>`)
-  }
-  return children.join('\n')
-}
-
-// el-checkbox-group 子级
-function buildElCheckboxGroupChild(scheme) {
-  const children = []
-  const slot = scheme.__slot__
-  const config = scheme.__config__
-  if (slot && slot.options && slot.options.length) {
-    const tag = config.optionType === 'button' ? 'el-checkbox-button' : 'el-checkbox'
-    const border = config.border ? 'border' : ''
-    children.push(`<${tag} v-for="(item, index) in ${scheme.__vModel__}Options" :key="index" :label="item.value" :disabled="item.disabled" ${border}>{{item.label}}</${tag}>`)
-  }
-  return children.join('\n')
-}
-
-// el-upload 子级
-function buildElUploadChild(scheme) {
-  const list = []
-  const config = scheme.__config__
-  if (scheme['list-type'] === 'picture-card') list.push('<i class="el-icon-plus"></i>')
-  else list.push(`<el-button size="small" type="primary" icon="el-icon-upload">${config.buttonText}</el-button>`)
-  if (config.showTip) list.push(`<div slot="tip" class="el-upload__tip">只能上传不超过 ${config.fileSize}${config.sizeUnit} 的${scheme.accept}文件</div>`)
-  return list.join('\n')
-}
-
-/**
- * 组装html代码。【入口函数】
- * @param {Object} formConfig 整个表单配置
- * @param {String} type 生成类型,文件或弹窗等
- */
-export function makeUpHtml(formConfig, type) {
-  const htmlList = []
-  confGlobal = formConfig
-  // 判断布局是否都沾满了24个栅格,以备后续简化代码结构
-  someSpanIsNot24 = formConfig.fields.some(item => item.__config__.span !== 24)
-  // 遍历渲染每个组件成html
-  formConfig.fields.forEach(el => {
-    htmlList.push(layouts[el.__config__.layout](el))
-  })
-  const htmlStr = htmlList.join('\n')
-  // 将组件代码放进form标签
-  let temp = buildFormTemplate(formConfig, htmlStr, type)
-  // dialog标签包裹代码
-  if (type === 'dialog') {
-    temp = dialogWrapper(temp)
-  }
-  confGlobal = null
-  return temp
-}

+ 0 - 271
yudao-admin-ui/src/utils/generator/js.js

@@ -1,271 +0,0 @@
-import { isArray } from 'util'
-import { exportDefault, titleCase, deepClone } from '@/utils/index'
-import ruleTrigger from './ruleTrigger'
-
-const units = {
-  KB: '1024',
-  MB: '1024 / 1024',
-  GB: '1024 / 1024 / 1024'
-}
-let confGlobal
-const inheritAttrs = {
-  file: '',
-  dialog: 'inheritAttrs: false,'
-}
-
-/**
- * 组装js 【入口函数】
- * @param {Object} formConfig 整个表单配置
- * @param {String} type 生成类型,文件或弹窗等
- */
-export function makeUpJs(formConfig, type) {
-  confGlobal = formConfig = deepClone(formConfig)
-  const dataList = []
-  const ruleList = []
-  const optionsList = []
-  const propsList = []
-  const methodList = mixinMethod(type)
-  const uploadVarList = []
-  const created = []
-
-  formConfig.fields.forEach(el => {
-    buildAttributes(el, dataList, ruleList, optionsList, methodList, propsList, uploadVarList, created)
-  })
-
-  const script = buildexport(
-    formConfig,
-    type,
-    dataList.join('\n'),
-    ruleList.join('\n'),
-    optionsList.join('\n'),
-    uploadVarList.join('\n'),
-    propsList.join('\n'),
-    methodList.join('\n'),
-    created.join('\n')
-  )
-  confGlobal = null
-  return script
-}
-
-// 构建组件属性
-function buildAttributes(scheme, dataList, ruleList, optionsList, methodList, propsList, uploadVarList, created) {
-  const config = scheme.__config__
-  const slot = scheme.__slot__
-  buildData(scheme, dataList)
-  buildRules(scheme, ruleList)
-
-  // 特殊处理options属性
-  if (scheme.options || (slot && slot.options && slot.options.length)) {
-    buildOptions(scheme, optionsList)
-    if (config.dataType === 'dynamic') {
-      const model = `${scheme.__vModel__}Options`
-      const options = titleCase(model)
-      const methodName = `get${options}`
-      buildOptionMethod(methodName, model, methodList, scheme)
-      callInCreated(methodName, created)
-    }
-  }
-
-  // 处理props
-  if (scheme.props && scheme.props.props) {
-    buildProps(scheme, propsList)
-  }
-
-  // 处理el-upload的action
-  if (scheme.action && config.tag === 'el-upload') {
-    uploadVarList.push(
-      `${scheme.__vModel__}Action: '${scheme.action}',
-      ${scheme.__vModel__}fileList: [],`
-    )
-    methodList.push(buildBeforeUpload(scheme))
-    // 非自动上传时,生成手动上传的函数
-    if (!scheme['auto-upload']) {
-      methodList.push(buildSubmitUpload(scheme))
-    }
-  }
-
-  // 构建子级组件属性
-  if (config.children) {
-    config.children.forEach(item => {
-      buildAttributes(item, dataList, ruleList, optionsList, methodList, propsList, uploadVarList, created)
-    })
-  }
-}
-
-// 在Created调用函数
-function callInCreated(methodName, created) {
-  created.push(`this.${methodName}()`)
-}
-
-// 混入处理函数
-function mixinMethod(type) {
-  const list = []; const
-    minxins = {
-      file: confGlobal.formBtns ? {
-        submitForm: `submitForm() {
-        this.$refs['${confGlobal.formRef}'].validate(valid => {
-          if(!valid) return
-          // TODO 提交表单
-        })
-      },`,
-        resetForm: `resetForm() {
-        this.$refs['${confGlobal.formRef}'].resetFields()
-      },`
-      } : null,
-      dialog: {
-        onOpen: 'onOpen() {},',
-        onClose: `onClose() {
-        this.$refs['${confGlobal.formRef}'].resetFields()
-      },`,
-        close: `close() {
-        this.$emit('update:visible', false)
-      },`,
-        handelConfirm: `handelConfirm() {
-        this.$refs['${confGlobal.formRef}'].validate(valid => {
-          if(!valid) return
-          this.close()
-        })
-      },`
-      }
-    }
-
-  const methods = minxins[type]
-  if (methods) {
-    Object.keys(methods).forEach(key => {
-      list.push(methods[key])
-    })
-  }
-
-  return list
-}
-
-// 构建data
-function buildData(scheme, dataList) {
-  const config = scheme.__config__
-  if (scheme.__vModel__ === undefined) return
-  const defaultValue = JSON.stringify(config.defaultValue)
-  dataList.push(`${scheme.__vModel__}: ${defaultValue},`)
-}
-
-// 构建校验规则
-function buildRules(scheme, ruleList) {
-  const config = scheme.__config__
-  if (scheme.__vModel__ === undefined) return
-  const rules = []
-  if (ruleTrigger[config.tag]) {
-    if (config.required) {
-      const type = isArray(config.defaultValue) ? 'type: \'array\',' : ''
-      let message = isArray(config.defaultValue) ? `请至少选择一个${config.label}` : scheme.placeholder
-      if (message === undefined) message = `${config.label}不能为空`
-      rules.push(`{ required: true, ${type} message: '${message}', trigger: '${ruleTrigger[config.tag]}' }`)
-    }
-    if (config.regList && isArray(config.regList)) {
-      config.regList.forEach(item => {
-        if (item.pattern) {
-          rules.push(
-            `{ pattern: ${eval(item.pattern)}, message: '${item.message}', trigger: '${ruleTrigger[config.tag]}' }`
-          )
-        }
-      })
-    }
-    ruleList.push(`${scheme.__vModel__}: [${rules.join(',')}],`)
-  }
-}
-
-// 构建options
-function buildOptions(scheme, optionsList) {
-  if (scheme.__vModel__ === undefined) return
-  // el-cascader直接有options属性,其他组件都是定义在slot中,所以有两处判断
-  let { options } = scheme
-  if (!options) options = scheme.__slot__.options
-  if (scheme.__config__.dataType === 'dynamic') { options = [] }
-  const str = `${scheme.__vModel__}Options: ${JSON.stringify(options)},`
-  optionsList.push(str)
-}
-
-function buildProps(scheme, propsList) {
-  const str = `${scheme.__vModel__}Props: ${JSON.stringify(scheme.props.props)},`
-  propsList.push(str)
-}
-
-// el-upload的BeforeUpload
-function buildBeforeUpload(scheme) {
-  const config = scheme.__config__
-  const unitNum = units[config.sizeUnit]; let rightSizeCode = ''; let acceptCode = ''; const
-    returnList = []
-  if (config.fileSize) {
-    rightSizeCode = `let isRightSize = file.size / ${unitNum} < ${config.fileSize}
-    if(!isRightSize){
-      this.$message.error('文件大小超过 ${config.fileSize}${config.sizeUnit}')
-    }`
-    returnList.push('isRightSize')
-  }
-  if (scheme.accept) {
-    acceptCode = `let isAccept = new RegExp('${scheme.accept}').test(file.type)
-    if(!isAccept){
-      this.$message.error('应该选择${scheme.accept}类型的文件')
-    }`
-    returnList.push('isAccept')
-  }
-  const str = `${scheme.__vModel__}BeforeUpload(file) {
-    ${rightSizeCode}
-    ${acceptCode}
-    return ${returnList.join('&&')}
-  },`
-  return returnList.length ? str : ''
-}
-
-// el-upload的submit
-function buildSubmitUpload(scheme) {
-  const str = `submitUpload() {
-    this.$refs['${scheme.__vModel__}'].submit()
-  },`
-  return str
-}
-
-function buildOptionMethod(methodName, model, methodList, scheme) {
-  const config = scheme.__config__
-  const str = `${methodName}() {
-    // 注意:this.$axios是通过Vue.prototype.$axios = axios挂载产生的
-    this.$axios({
-      method: '${config.method}',
-      url: '${config.url}'
-    }).then(resp => {
-      var { data } = resp
-      this.${model} = data.${config.dataPath}
-    })
-  },`
-  methodList.push(str)
-}
-
-// js整体拼接
-function buildexport(conf, type, data, rules, selectOptions, uploadVar, props, methods, created) {
-  const str = `${exportDefault}{
-  ${inheritAttrs[type]}
-  components: {},
-  props: [],
-  data () {
-    return {
-      ${conf.formModel}: {
-        ${data}
-      },
-      ${conf.formRules}: {
-        ${rules}
-      },
-      ${uploadVar}
-      ${selectOptions}
-      ${props}
-    }
-  },
-  computed: {},
-  watch: {},
-  created () {
-    ${created}
-  },
-  mounted () {},
-  methods: {
-    ${methods}
-  }
-}`
-  return str
-}

+ 0 - 126
yudao-admin-ui/src/utils/generator/render.js

@@ -1,126 +0,0 @@
-import { makeMap } from '@/utils/index'
-
-// 参考https://github.com/vuejs/vue/blob/v2.6.10/src/platforms/web/server/util.js
-const isAttr = makeMap(
-  'accept,accept-charset,accesskey,action,align,alt,async,autocomplete,'
-  + 'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,'
-  + 'checked,cite,class,code,codebase,color,cols,colspan,content,http-equiv,'
-  + 'name,contenteditable,contextmenu,controls,coords,data,datetime,default,'
-  + 'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,method,for,'
-  + 'form,formaction,headers,height,hidden,high,href,hreflang,http-equiv,'
-  + 'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,'
-  + 'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,'
-  + 'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,'
-  + 'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,'
-  + 'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,'
-  + 'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,'
-  + 'target,title,type,usemap,value,width,wrap'
-)
-
-function vModel(self, dataObject, defaultValue) {
-  dataObject.props.value = defaultValue
-
-  dataObject.on.input = val => {
-    self.$emit('input', val)
-  }
-}
-
-const componentChild = {
-  'el-button': {
-    default(h, conf, key) {
-      return conf[key]
-    },
-  },
-  'el-input': {
-    prepend(h, conf, key) {
-      return <template slot="prepend">{conf[key]}</template>
-    },
-    append(h, conf, key) {
-      return <template slot="append">{conf[key]}</template>
-    }
-  },
-  'el-select': {
-    options(h, conf, key) {
-      const list = []
-      conf.options.forEach(item => {
-        list.push(<el-option label={item.label} value={item.value} disabled={item.disabled}></el-option>)
-      })
-      return list
-    }
-  },
-  'el-radio-group': {
-    options(h, conf, key) {
-      const list = []
-      conf.options.forEach(item => {
-        if (conf.optionType === 'button') list.push(<el-radio-button label={item.value}>{item.label}</el-radio-button>)
-        else list.push(<el-radio label={item.value} border={conf.border}>{item.label}</el-radio>)
-      })
-      return list
-    }
-  },
-  'el-checkbox-group': {
-    options(h, conf, key) {
-      const list = []
-      conf.options.forEach(item => {
-        if (conf.optionType === 'button') {
-          list.push(<el-checkbox-button label={item.value}>{item.label}</el-checkbox-button>)
-        } else {
-          list.push(<el-checkbox label={item.value} border={conf.border}>{item.label}</el-checkbox>)
-        }
-      })
-      return list
-    }
-  },
-  'el-upload': {
-    'list-type': (h, conf, key) => {
-      const list = []
-      if (conf['list-type'] === 'picture-card') {
-        list.push(<i class="el-icon-plus"></i>)
-      } else {
-        list.push(<el-button size="small" type="primary" icon="el-icon-upload">{conf.buttonText}</el-button>)
-      }
-      if (conf.showTip) {
-        list.push(<div slot="tip" class="el-upload__tip">只能上传不超过 {conf.fileSize}{conf.sizeUnit} 的{conf.accept}文件</div>)
-      }
-      return list
-    }
-  }
-}
-
-export default {
-  render(h) {
-    const dataObject = {
-      attrs: {},
-      props: {},
-      on: {},
-      style: {}
-    }
-    const confClone = JSON.parse(JSON.stringify(this.conf))
-    const children = []
-
-    const childObjs = componentChild[confClone.tag]
-    if (childObjs) {
-      Object.keys(childObjs).forEach(key => {
-        const childFunc = childObjs[key]
-        if (confClone[key]) {
-          children.push(childFunc(h, confClone, key))
-        }
-      })
-    }
-
-    Object.keys(confClone).forEach(key => {
-      const val = confClone[key]
-      if (key === 'vModel') {
-        vModel(this, dataObject, confClone.defaultValue)
-      } else if (dataObject[key]) {
-        dataObject[key] = val
-      } else if (!isAttr(key)) {
-        dataObject.props[key] = val
-      } else {
-        dataObject.attrs[key] = val
-      }
-    })
-    return h(this.conf.tag, dataObject, children)
-  },
-  props: ['conf']
-}

+ 0 - 16
yudao-admin-ui/src/utils/generator/ruleTrigger.js

@@ -1,16 +0,0 @@
-/**
- * 用于生成表单校验,指定正则规则的触发方式。
- * 未在此处声明无触发方式的组件将不生成rule!!
- */
-export default {
-  'el-input': 'blur',
-  'el-input-number': 'blur',
-  'el-select': 'change',
-  'el-radio-group': 'change',
-  'el-checkbox-group': 'change',
-  'el-cascader': 'change',
-  'el-time-picker': 'change',
-  'el-date-picker': 'change',
-  'el-rate': 'change',
-  tinymce: 'blur'
-}

+ 0 - 0
yudao-admin-ui/src/utils/generator/icon.json → yudao-admin-ui/src/utils/icon.json


+ 0 - 188
yudao-admin-ui/src/utils/parser/Parser.vue

@@ -1,188 +0,0 @@
-<script>
-import { deepClone } from '@/utils/index'
-// import render from '@/components/render/render.js'
-import render from '../render/render.js' // edit by 芋道源码
-
-const ruleTrigger = {
-  'el-input': 'blur',
-  'el-input-number': 'blur',
-  'el-select': 'change',
-  'el-radio-group': 'change',
-  'el-checkbox-group': 'change',
-  'el-cascader': 'change',
-  'el-time-picker': 'change',
-  'el-date-picker': 'change',
-  'el-rate': 'change'
-}
-
-const layouts = {
-  colFormItem(h, scheme) {
-    const config = scheme.__config__
-    const listeners = buildListeners.call(this, scheme)
-
-    let labelWidth = config.labelWidth ? `${config.labelWidth}px` : null
-    if (config.showLabel === false) labelWidth = '0'
-    return (
-      <el-col span={config.span}>
-        <el-form-item label-width={labelWidth} prop={scheme.__vModel__}
-          label={config.showLabel ? config.label : ''}>
-          <render conf={scheme} on={listeners} />
-        </el-form-item>
-      </el-col>
-    )
-  },
-  rowFormItem(h, scheme) {
-    let child = renderChildren.apply(this, arguments)
-    if (scheme.type === 'flex') {
-      child = <el-row type={scheme.type} justify={scheme.justify} align={scheme.align}>
-              {child}
-            </el-row>
-    }
-    return (
-      <el-col span={scheme.span}>
-        <el-row gutter={scheme.gutter}>
-          {child}
-        </el-row>
-      </el-col>
-    )
-  }
-}
-
-function renderFrom(h) {
-  const { formConfCopy } = this
-
-  return (
-    <el-row gutter={formConfCopy.gutter}>
-      <el-form
-        size={formConfCopy.size}
-        label-position={formConfCopy.labelPosition}
-        disabled={formConfCopy.disabled}
-        label-width={`${formConfCopy.labelWidth}px`}
-        ref={formConfCopy.formRef}
-        // model不能直接赋值 https://github.com/vuejs/jsx/issues/49#issuecomment-472013664
-        props={{ model: this[formConfCopy.formModel] }}
-        rules={this[formConfCopy.formRules]}
-      >
-        {renderFormItem.call(this, h, formConfCopy.fields)}
-        {formConfCopy.formBtns && formBtns.call(this, h)}
-      </el-form>
-    </el-row>
-  )
-}
-
-function formBtns(h) {
-  return <el-col>
-    <el-form-item size="large">
-      <el-button type="primary" onClick={this.submitForm}>提交</el-button>
-      <el-button onClick={this.resetForm}>重置</el-button>
-    </el-form-item>
-  </el-col>
-}
-
-function renderFormItem(h, elementList) {
-  return elementList.map(scheme => {
-    const config = scheme.__config__
-    const layout = layouts[config.layout]
-
-    if (layout) {
-      return layout.call(this, h, scheme)
-    }
-    throw new Error(`没有与${config.layout}匹配的layout`)
-  })
-}
-
-function renderChildren(h, scheme) {
-  const config = scheme.__config__
-  if (!Array.isArray(config.children)) return null
-  return renderFormItem.call(this, h, config.children)
-}
-
-function setValue(event, config, scheme) {
-  this.$set(config, 'defaultValue', event)
-  this.$set(this[this.formConf.formModel], scheme.__vModel__, event)
-}
-
-function buildListeners(scheme) {
-  const config = scheme.__config__
-  const methods = this.formConf.__methods__ || {}
-  const listeners = {}
-
-  // 给__methods__中的方法绑定this和event
-  Object.keys(methods).forEach(key => {
-    listeners[key] = event => methods[key].call(this, event)
-  })
-  // 响应 render.js 中的 vModel $emit('input', val)
-  listeners.input = event => setValue.call(this, event, config, scheme)
-
-  return listeners
-}
-
-export default {
-  components: {
-    render
-  },
-  props: {
-    formConf: {
-      type: Object,
-      required: true
-    }
-  },
-  data() {
-    const data = {
-      formConfCopy: deepClone(this.formConf),
-      [this.formConf.formModel]: {},
-      [this.formConf.formRules]: {}
-    }
-    this.initFormData(data.formConfCopy.fields, data[this.formConf.formModel])
-    this.buildRules(data.formConfCopy.fields, data[this.formConf.formRules])
-    return data
-  },
-  methods: {
-    initFormData(componentList, formData) {
-      componentList.forEach(cur => {
-        const config = cur.__config__
-        if (cur.__vModel__) formData[cur.__vModel__] = config.defaultValue
-        // debugger
-        if (config.children) this.initFormData(config.children, formData)
-      })
-    },
-    buildRules(componentList, rules) {
-      componentList.forEach(cur => {
-        const config = cur.__config__
-        if (Array.isArray(config.regList)) {
-          if (config.required) {
-            const required = { required: config.required, message: cur.placeholder }
-            if (Array.isArray(config.defaultValue)) {
-              required.type = 'array'
-              required.message = `请至少选择一个${config.label}`
-            }
-            required.message === undefined && (required.message = `${config.label}不能为空`)
-            config.regList.push(required)
-          }
-          rules[cur.__vModel__] = config.regList.map(item => {
-            item.pattern && (item.pattern = eval(item.pattern))
-            item.trigger = ruleTrigger && ruleTrigger[config.tag]
-            return item
-          })
-        }
-        if (config.children) this.buildRules(config.children, rules)
-      })
-    },
-    resetForm() {
-      this.formConfCopy = deepClone(this.formConf)
-      this.$refs[this.formConf.formRef].resetFields()
-    },
-    submitForm() {
-      this.$refs[this.formConf.formRef].validate(valid => {
-        if (!valid) return false
-        // 触发sumit事件
-        this.$emit('submit', this[this.formConf.formModel])
-        return true
-      })
-    }
-  },
-  render(h) {
-    return renderFrom.call(this, h)
-  }
-}
-</script>

+ 0 - 19
yudao-admin-ui/src/utils/parser/README.md

@@ -1,19 +0,0 @@
-## form-generator JSON 解析器
->用于将form-generator导出的JSON解析成一个表单。
-
-### 安装组件
-```
-npm i form-gen-parser
-```
-或者
-```
-yarn add form-gen-parser
-```
-
-### 使用示例
-> [查看在线示例](https://mrhj.gitee.io/form-generator/#/parser)  
-
-示例代码:  
-> [src\components\parser\example\Index.vue](https://github.com/JakHuang/form-generator/blob/dev/src/components/parser/example/Index.vue)
-
-【add by 芋道源码】https://github.com/JakHuang/form-generator/blob/dev/src/components/parser/

+ 0 - 324
yudao-admin-ui/src/utils/parser/example/Index.vue

@@ -1,324 +0,0 @@
-<template>
-  <div class="test-form">
-    <parser :form-conf="formConf" @submit="sumbitForm1" />
-    <parser :key="key2" :form-conf="formConf" @submit="sumbitForm2" />
-    <el-button @click="change">
-      change
-    </el-button>
-  </div>
-</template>
-
-<script>
-import Parser from '../Parser'
-
-// 若parser是通过安装npm方式集成到项目中的,使用此行引入
-// import Parser from 'form-gen-parser'
-
-export default {
-  components: {
-    Parser
-  },
-  props: {},
-  data() {
-    return {
-      key2: +new Date(),
-      formConf: {
-        fields: [
-          {
-            __config__: {
-              label: '单行文本',
-              labelWidth: null,
-              showLabel: true,
-              changeTag: true,
-              tag: 'el-input',
-              tagIcon: 'input',
-              required: true,
-              layout: 'colFormItem',
-              span: 24,
-              document: 'https://element.eleme.cn/#/zh-CN/component/input',
-              regList: [
-                {
-                  pattern: '/^1(3|4|5|7|8|9)\\d{9}$/',
-                  message: '手机号格式错误'
-                }
-              ]
-            },
-            __slot__: {
-              prepend: '',
-              append: ''
-            },
-            __vModel__: 'mobile',
-            placeholder: '请输入手机号',
-            style: {
-              width: '100%'
-            },
-            clearable: true,
-            'prefix-icon': 'el-icon-mobile',
-            'suffix-icon': '',
-            maxlength: 11,
-            'show-word-limit': true,
-            readonly: false,
-            disabled: false
-          },
-          {
-            __config__: {
-              label: '日期范围',
-              tag: 'el-date-picker',
-              tagIcon: 'date-range',
-              defaultValue: null,
-              span: 24,
-              showLabel: true,
-              labelWidth: null,
-              required: true,
-              layout: 'colFormItem',
-              regList: [],
-              changeTag: true,
-              document:
-                'https://element.eleme.cn/#/zh-CN/component/date-picker',
-              formId: 101,
-              renderKey: 1585980082729
-            },
-            style: {
-              width: '100%'
-            },
-            type: 'daterange',
-            'range-separator': '至',
-            'start-placeholder': '开始日期',
-            'end-placeholder': '结束日期',
-            disabled: false,
-            clearable: true,
-            format: 'yyyy-MM-dd',
-            'value-format': 'yyyy-MM-dd',
-            readonly: false,
-            __vModel__: 'field101'
-          },
-          {
-            __config__: {
-              layout: 'rowFormItem',
-              tagIcon: 'row',
-              label: '行容器',
-              layoutTree: true,
-              children: [
-                {
-                  __config__: {
-                    label: '评分',
-                    tag: 'el-rate',
-                    tagIcon: 'rate',
-                    defaultValue: 0,
-                    span: 24,
-                    showLabel: true,
-                    labelWidth: null,
-                    layout: 'colFormItem',
-                    required: true,
-                    regList: [],
-                    changeTag: true,
-                    document: 'https://element.eleme.cn/#/zh-CN/component/rate',
-                    formId: 102,
-                    renderKey: 1586839671259
-                  },
-                  style: {},
-                  max: 5,
-                  'allow-half': false,
-                  'show-text': false,
-                  'show-score': false,
-                  disabled: false,
-                  __vModel__: 'field102'
-                }
-              ],
-              document: 'https://element.eleme.cn/#/zh-CN/component/layout',
-              formId: 101,
-              span: 24,
-              renderKey: 1586839668999,
-              componentName: 'row101',
-              gutter: 15
-            },
-            type: 'default',
-            justify: 'start',
-            align: 'top'
-          },
-          {
-            __config__: {
-              label: '按钮',
-              showLabel: true,
-              changeTag: true,
-              labelWidth: null,
-              tag: 'el-button',
-              tagIcon: 'button',
-              span: 24,
-              layout: 'colFormItem',
-              document: 'https://element.eleme.cn/#/zh-CN/component/button',
-              renderKey: 1594288459289
-            },
-            __slot__: {
-              default: '测试按钮1'
-            },
-            type: 'primary',
-            icon: 'el-icon-search',
-            round: false,
-            size: 'medium',
-            plain: false,
-            circle: false,
-            disabled: false,
-            on: {
-              click: 'clickTestButton1'
-            }
-          }
-        ],
-        __methods__: {
-          clickTestButton1() {
-            console.log(
-              `%c【测试按钮1】点击事件里可以访问当前表单:
-                1) formModel='formData', 所以this.formData可以拿到当前表单的model
-                2) formRef='elForm', 所以this.$refs.elForm可以拿到当前表单的ref(vue组件)
-              `,
-              'color:#409EFF;font-size: 15px'
-            )
-            console.log('表单的Model:', this.formData)
-            console.log('表单的ref:', this.$refs.elForm)
-          }
-        },
-        formRef: 'elForm',
-        formModel: 'formData',
-        size: 'small',
-        labelPosition: 'right',
-        labelWidth: 100,
-        formRules: 'rules',
-        gutter: 15,
-        disabled: false,
-        span: 24,
-        formBtns: true,
-        unFocusedComponentBorder: false
-      },
-      formConf2: {
-        fields: [
-          {
-            __config__: {
-              label: '单行文本',
-              labelWidth: null,
-              showLabel: true,
-              changeTag: true,
-              tag: 'el-input',
-              tagIcon: 'input',
-              required: true,
-              layout: 'colFormItem',
-              span: 24,
-              document: 'https://element.eleme.cn/#/zh-CN/component/input',
-              regList: [
-                {
-                  pattern: '/^1(3|4|5|7|8|9)\\d{9}$/',
-                  message: '手机号格式错误'
-                }
-              ]
-            },
-            __slot__: {
-              prepend: '',
-              append: ''
-            },
-            __vModel__: 'mobile',
-            placeholder: '请输入手机号',
-            style: {
-              width: '100%'
-            },
-            clearable: true,
-            'prefix-icon': 'el-icon-mobile',
-            'suffix-icon': '',
-            maxlength: 11,
-            'show-word-limit': true,
-            readonly: false,
-            disabled: false
-          },
-          {
-            __config__: {
-              label: '日期范围',
-              tag: 'el-date-picker',
-              tagIcon: 'date-range',
-              defaultValue: null,
-              span: 24,
-              showLabel: true,
-              labelWidth: null,
-              required: true,
-              layout: 'colFormItem',
-              regList: [],
-              changeTag: true,
-              document:
-                'https://element.eleme.cn/#/zh-CN/component/date-picker',
-              formId: 101,
-              renderKey: 1585980082729
-            },
-            style: {
-              width: '100%'
-            },
-            type: 'daterange',
-            'range-separator': '至',
-            'start-placeholder': '开始日期',
-            'end-placeholder': '结束日期',
-            disabled: false,
-            clearable: true,
-            format: 'yyyy-MM-dd',
-            'value-format': 'yyyy-MM-dd',
-            readonly: false,
-            __vModel__: 'field101'
-          }
-        ],
-        formRef: 'elForm',
-        formModel: 'formData',
-        size: 'small',
-        labelPosition: 'right',
-        labelWidth: 100,
-        formRules: 'rules',
-        gutter: 15,
-        disabled: false,
-        span: 24,
-        formBtns: true,
-        unFocusedComponentBorder: false
-      }
-    }
-  },
-  computed: {},
-  watch: {},
-  created() {},
-  mounted() {
-    // 表单数据回填,模拟异步请求场景
-    setTimeout(() => {
-      // 请求回来的表单数据
-      const data = {
-        mobile: '18836662555'
-      }
-      // 回填数据
-      this.fillFormData(this.formConf, data)
-      // 更新表单
-      this.key2 = +new Date()
-    }, 2000)
-  },
-  methods: {
-    fillFormData(form, data) {
-      form.fields.forEach(item => {
-        const val = data[item.__vModel__]
-        if (val) {
-          item.__config__.defaultValue = val
-        }
-      })
-    },
-    change() {
-      this.key2 = +new Date()
-      const t = this.formConf
-      this.formConf = this.formConf2
-      this.formConf2 = t
-    },
-    sumbitForm1(data) {
-      console.log('sumbitForm1提交数据:', data)
-    },
-    sumbitForm2(data) {
-      console.log('sumbitForm2提交数据:', data)
-    }
-  }
-}
-</script>
-
-<style lang="scss" scoped>
-.test-form {
-  margin: 15px auto;
-  width: 800px;
-  padding: 15px;
-}
-</style>

+ 0 - 3
yudao-admin-ui/src/utils/parser/index.js

@@ -1,3 +0,0 @@
-import Parser from './Parser'
-
-export default Parser

+ 0 - 25
yudao-admin-ui/src/utils/parser/package.json

@@ -1,25 +0,0 @@
-{
-  "name": "form-gen-parser",
-  "version": "1.0.3",
-  "description": "表单json解析器",
-  "main": "lib/form-gen-parser.umd.js",
-  "directories": {
-    "example": "example"
-  },
-  "scripts": {
-    "test": "echo \"Error: no test specified\" && exit 1"
-  },
-  "repository": {
-    "type": "git",
-    "url": "git+https://github.com/JakHuang/form-generator.git"
-  },
-  "dependencies": {
-    "form-gen-render": "^1.0.0"
-  },
-  "author": "jakHuang",
-  "license": "MIT",
-  "bugs": {
-    "url": "https://github.com/JakHuang/form-generator/issues"
-  },
-  "homepage": "https://github.com/JakHuang/form-generator/blob/dev/src/components/parser"
-}

+ 0 - 1
yudao-admin-ui/src/utils/render/README.md

@@ -1 +0,0 @@
-【add by 芋道源码】https://github.com/JakHuang/form-generator/blob/dev/src/components/render/

+ 0 - 19
yudao-admin-ui/src/utils/render/package.json

@@ -1,19 +0,0 @@
-{
-  "name": "form-gen-render",
-  "version": "1.0.4",
-  "description": "表单核心render",
-  "main": "lib/form-gen-render.umd.js",
-  "scripts": {
-    "test": "echo \"Error: no test specified\" && exit 1"
-  },
-  "repository": {
-    "type": "git",
-    "url": "git+https://github.com/JakHuang/form-generator.git"
-  },
-  "author": "jakhuang",
-  "license": "MIT",
-  "bugs": {
-    "url": "https://github.com/JakHuang/form-generator/issues"
-  },
-  "homepage": "https://github.com/JakHuang/form-generator#readme"
-}

+ 0 - 122
yudao-admin-ui/src/utils/render/render.js

@@ -1,122 +0,0 @@
-import { deepClone } from '@/utils/index'
-
-const componentChild = {}
-/**
- * 将./slots中的文件挂载到对象componentChild上
- * 文件名为key,对应JSON配置中的__config__.tag
- * 文件内容为value,解析JSON配置中的__slot__
- */
-const slotsFiles = require.context('./slots', false, /\.js$/)
-const keys = slotsFiles.keys() || []
-keys.forEach(key => {
-  const tag = key.replace(/^\.\/(.*)\.\w+$/, '$1')
-  const value = slotsFiles(key).default
-  componentChild[tag] = value
-})
-
-function vModel(dataObject, defaultValue) {
-  dataObject.props.value = defaultValue
-
-  dataObject.on.input = val => {
-    this.$emit('input', val)
-  }
-}
-
-function mountSlotFiles(h, confClone, children) {
-  const childObjs = componentChild[confClone.__config__.tag]
-  if (childObjs) {
-    Object.keys(childObjs).forEach(key => {
-      const childFunc = childObjs[key]
-      if (confClone.__slot__ && confClone.__slot__[key]) {
-        children.push(childFunc(h, confClone, key))
-      }
-    })
-  }
-}
-
-function emitEvents(confClone) {
-  ['on', 'nativeOn'].forEach(attr => {
-    const eventKeyList = Object.keys(confClone[attr] || {})
-    eventKeyList.forEach(key => {
-      const val = confClone[attr][key]
-      if (typeof val === 'string') {
-        confClone[attr][key] = event => this.$emit(val, event)
-      }
-    })
-  })
-}
-
-function buildDataObject(confClone, dataObject) {
-  Object.keys(confClone).forEach(key => {
-    const val = confClone[key]
-    if (key === '__vModel__') {
-      vModel.call(this, dataObject, confClone.__config__.defaultValue)
-    } else if (dataObject[key] !== undefined) {
-      if (dataObject[key] === null
-        || dataObject[key] instanceof RegExp
-        || ['boolean', 'string', 'number', 'function'].includes(typeof dataObject[key])) {
-        dataObject[key] = val
-      } else if (Array.isArray(dataObject[key])) {
-        dataObject[key] = [...dataObject[key], ...val]
-      } else {
-        dataObject[key] = { ...dataObject[key], ...val }
-      }
-    } else {
-      dataObject.attrs[key] = val
-    }
-  })
-
-  // 清理属性
-  clearAttrs(dataObject)
-}
-
-function clearAttrs(dataObject) {
-  delete dataObject.attrs.__config__
-  delete dataObject.attrs.__slot__
-  delete dataObject.attrs.__methods__
-}
-
-function makeDataObject() {
-  // 深入数据对象:
-  // https://cn.vuejs.org/v2/guide/render-function.html#%E6%B7%B1%E5%85%A5%E6%95%B0%E6%8D%AE%E5%AF%B9%E8%B1%A1
-  return {
-    class: {},
-    attrs: {},
-    props: {},
-    domProps: {},
-    nativeOn: {},
-    on: {},
-    style: {},
-    directives: [],
-    scopedSlots: {},
-    slot: null,
-    key: null,
-    ref: null,
-    refInFor: true
-  }
-}
-
-export default {
-  props: {
-    conf: {
-      type: Object,
-      required: true
-    }
-  },
-  render(h) {
-    const dataObject = makeDataObject()
-    const confClone = deepClone(this.conf)
-    const children = this.$slots.default || []
-
-    // 如果slots文件夹存在与当前tag同名的文件,则执行文件中的代码
-    mountSlotFiles.call(this, h, confClone, children)
-
-    // 将字符串类型的事件,发送为消息
-    emitEvents.call(this, confClone)
-
-    // 将json表单配置转化为vue render可以识别的 “数据对象(dataObject)”
-    buildDataObject.call(this, confClone, dataObject)
-
-    return h(this.conf.__config__.tag, dataObject, children)
-  }
-}

+ 0 - 5
yudao-admin-ui/src/utils/render/slots/el-button.js

@@ -1,5 +0,0 @@
-export default {
-  default(h, conf, key) {
-    return conf.__slot__[key]
-  }
-}

+ 0 - 13
yudao-admin-ui/src/utils/render/slots/el-checkbox-group.js

@@ -1,13 +0,0 @@
-export default {
-  options(h, conf, key) {
-    const list = []
-    conf.__slot__.options.forEach(item => {
-      if (conf.__config__.optionType === 'button') {
-        list.push(<el-checkbox-button label={item.value}>{item.label}</el-checkbox-button>)
-      } else {
-        list.push(<el-checkbox label={item.value} border={conf.border}>{item.label}</el-checkbox>)
-      }
-    })
-    return list
-  }
-}

+ 0 - 8
yudao-admin-ui/src/utils/render/slots/el-input.js

@@ -1,8 +0,0 @@
-export default {
-  prepend(h, conf, key) {
-    return <template slot="prepend">{conf.__slot__[key]}</template>
-  },
-  append(h, conf, key) {
-    return <template slot="append">{conf.__slot__[key]}</template>
-  }
-}

+ 0 - 13
yudao-admin-ui/src/utils/render/slots/el-radio-group.js

@@ -1,13 +0,0 @@
-export default {
-  options(h, conf, key) {
-    const list = []
-    conf.__slot__.options.forEach(item => {
-      if (conf.__config__.optionType === 'button') {
-        list.push(<el-radio-button label={item.value}>{item.label}</el-radio-button>)
-      } else {
-        list.push(<el-radio label={item.value} border={conf.border}>{item.label}</el-radio>)
-      }
-    })
-    return list
-  }
-}

+ 0 - 9
yudao-admin-ui/src/utils/render/slots/el-select.js

@@ -1,9 +0,0 @@
-export default {
-  options(h, conf, key) {
-    const list = []
-    conf.__slot__.options.forEach(item => {
-      list.push(<el-option label={item.label} value={item.value} disabled={item.disabled}></el-option>)
-    })
-    return list
-  }
-}

+ 0 - 17
yudao-admin-ui/src/utils/render/slots/el-upload.js

@@ -1,17 +0,0 @@
-export default {
-  'list-type': (h, conf, key) => {
-    const list = []
-    const config = conf.__config__
-    if (conf['list-type'] === 'picture-card') {
-      list.push(<i class="el-icon-plus"></i>)
-    } else {
-      list.push(<el-button size="small" type="primary" icon="el-icon-upload">{config.buttonText}</el-button>)
-    }
-    if (config.showTip) {
-      list.push(
-        <div slot="tip" class="el-upload__tip">只能上传不超过 {config.fileSize}{config.sizeUnit} 的{conf.accept}文件</div>
-      )
-    }
-    return list
-  }
-}

+ 1 - 1
yudao-admin-ui/src/views/bpm/form/formEditor.vue

@@ -150,7 +150,7 @@ import JsonDrawer from '@/views/tool/build/JsonDrawer'
 import RightPanel from '@/views/tool/build/RightPanel'
 import {
   inputComponents, selectComponents, layoutComponents, formConf
-} from '@/utils/generator/config'
+} from '@/components/generator/config'
 import {
   exportDefault, beautifierConf, isNumberStr, titleCase, deepClone, isObjectObject
 } from '@/utils/index'

+ 173 - 173
yudao-admin-ui/src/views/bpm/form/index.vue

@@ -62,7 +62,7 @@
 
 <script>
 import {deleteForm, getForm, getFormPage} from "@/api/bpm/form";
-import Parser from '@/utils/parser/Parser'
+import Parser from '@/components/parser/Parser'
 
 export default {
   name: "Form",
@@ -121,181 +121,181 @@ export default {
       this.detailOpen = true
       getForm(row.id).then(response => {
         const data = response.data
-        // this.detailForm = {
-        //   ...JSON.parse(data.conf),
-        //   fields: this.decodeFields(data.fields)
-        // }
-        console.log({
+        this.detailForm = {
           ...JSON.parse(data.conf),
           fields: this.decodeFields(data.fields)
-        })
-        this.detailForm = {
-          fields: [
-            {
-              __config__: {
-                label: '单行文本',
-                labelWidth: null,
-                showLabel: true,
-                changeTag: true,
-                tag: 'el-input',
-                tagIcon: 'input',
-                required: true,
-                layout: 'colFormItem',
-                span: 24,
-                document: 'https://element.eleme.cn/#/zh-CN/component/input',
-                regList: [
-                  {
-                    pattern: '/^1(3|4|5|7|8|9)\\d{9}$/',
-                    message: '手机号格式错误'
-                  }
-                ]
-              },
-              __slot__: {
-                prepend: '',
-                append: ''
-              },
-              __vModel__: 'mobile',
-              placeholder: '请输入手机号',
-              style: {
-                width: '100%'
-              },
-              clearable: true,
-              'prefix-icon': 'el-icon-mobile',
-              'suffix-icon': '',
-              maxlength: 11,
-              'show-word-limit': true,
-              readonly: false,
-              disabled: false
-            },
-            {
-              __config__: {
-                label: '日期范围',
-                tag: 'el-date-picker',
-                tagIcon: 'date-range',
-                defaultValue: null,
-                span: 24,
-                showLabel: true,
-                labelWidth: null,
-                required: true,
-                layout: 'colFormItem',
-                regList: [],
-                changeTag: true,
-                document:
-                  'https://element.eleme.cn/#/zh-CN/component/date-picker',
-                formId: 101,
-                renderKey: 1585980082729
-              },
-              style: {
-                width: '100%'
-              },
-              type: 'daterange',
-              'range-separator': '至',
-              'start-placeholder': '开始日期',
-              'end-placeholder': '结束日期',
-              disabled: false,
-              clearable: true,
-              format: 'yyyy-MM-dd',
-              'value-format': 'yyyy-MM-dd',
-              readonly: false,
-              __vModel__: 'field101'
-            },
-            {
-              __config__: {
-                layout: 'rowFormItem',
-                tagIcon: 'row',
-                label: '行容器',
-                layoutTree: true,
-                children: [
-                  {
-                    __config__: {
-                      label: '评分',
-                      tag: 'el-rate',
-                      tagIcon: 'rate',
-                      defaultValue: 0,
-                      span: 24,
-                      showLabel: true,
-                      labelWidth: null,
-                      layout: 'colFormItem',
-                      required: true,
-                      regList: [],
-                      changeTag: true,
-                      document: 'https://element.eleme.cn/#/zh-CN/component/rate',
-                      formId: 102,
-                      renderKey: 1586839671259
-                    },
-                    style: {},
-                    max: 5,
-                    'allow-half': false,
-                    'show-text': false,
-                    'show-score': false,
-                    disabled: false,
-                    __vModel__: 'field102'
-                  }
-                ],
-                document: 'https://element.eleme.cn/#/zh-CN/component/layout',
-                formId: 101,
-                span: 24,
-                renderKey: 1586839668999,
-                componentName: 'row101',
-                gutter: 15
-              },
-              type: 'default',
-              justify: 'start',
-              align: 'top'
-            },
-            {
-              __config__: {
-                label: '按钮',
-                showLabel: true,
-                changeTag: true,
-                labelWidth: null,
-                tag: 'el-button',
-                tagIcon: 'button',
-                span: 24,
-                layout: 'colFormItem',
-                document: 'https://element.eleme.cn/#/zh-CN/component/button',
-                renderKey: 1594288459289
-              },
-              __slot__: {
-                default: '测试按钮1'
-              },
-              type: 'primary',
-              icon: 'el-icon-search',
-              round: false,
-              size: 'medium',
-              plain: false,
-              circle: false,
-              disabled: false,
-              on: {
-                click: 'clickTestButton1'
-              }
-            }
-          ],
-          __methods__: {
-            clickTestButton1() {
-              console.log(
-                `%c【测试按钮1】点击事件里可以访问当前表单:
-                1) formModel='formData', 所以this.formData可以拿到当前表单的model
-                2) formRef='elForm', 所以this.$refs.elForm可以拿到当前表单的ref(vue组件)
-              `,
-                'color:#409EFF;font-size: 15px'
-              )
-              console.log('表单的Model:', this.formData)
-              console.log('表单的ref:', this.$refs.elForm)
-            }
-          },
-          formRef: 'elForm',
-          formModel: 'formData',
-          size: 'small',
-          labelPosition: 'right',
-          labelWidth: 100,
-          formRules: 'rules',
-          gutter: 15,
-          disabled: false,
-          span: 24,
-          formBtns: true,
-          unFocusedComponentBorder: false
         }
+        // console.log({
+        //   ...JSON.parse(data.conf),
+        //   fields: this.decodeFields(data.fields)
+        // })
+      //   this.detailForm = {
+      //     fields: [
+      //       {
+      //         __config__: {
+      //           label: '单行文本',
+      //           labelWidth: null,
+      //           showLabel: true,
+      //           changeTag: true,
+      //           tag: 'el-input',
+      //           tagIcon: 'input',
+      //           required: true,
+      //           layout: 'colFormItem',
+      //           span: 24,
+      //           document: 'https://element.eleme.cn/#/zh-CN/component/input',
+      //           regList: [
+      //             {
+      //               pattern: '/^1(3|4|5|7|8|9)\\d{9}$/',
+      //               message: '手机号格式错误'
+      //             }
+      //           ]
+      //         },
+      //         __slot__: {
+      //           prepend: '',
+      //           append: ''
+      //         },
+      //         __vModel__: 'mobile',
+      //         placeholder: '请输入手机号',
+      //         style: {
+      //           width: '100%'
+      //         },
+      //         clearable: true,
+      //         'prefix-icon': 'el-icon-mobile',
+      //         'suffix-icon': '',
+      //         maxlength: 11,
+      //         'show-word-limit': true,
+      //         readonly: false,
+      //         disabled: false
+      //       },
+      //       {
+      //         __config__: {
+      //           label: '日期范围',
+      //           tag: 'el-date-picker',
+      //           tagIcon: 'date-range',
+      //           defaultValue: null,
+      //           span: 24,
+      //           showLabel: true,
+      //           labelWidth: null,
+      //           required: true,
+      //           layout: 'colFormItem',
+      //           regList: [],
+      //           changeTag: true,
+      //           document:
+      //             'https://element.eleme.cn/#/zh-CN/component/date-picker',
+      //           formId: 101,
+      //           renderKey: 1585980082729
+      //         },
+      //         style: {
+      //           width: '100%'
+      //         },
+      //         type: 'daterange',
+      //         'range-separator': '至',
+      //         'start-placeholder': '开始日期',
+      //         'end-placeholder': '结束日期',
+      //         disabled: false,
+      //         clearable: true,
+      //         format: 'yyyy-MM-dd',
+      //         'value-format': 'yyyy-MM-dd',
+      //         readonly: false,
+      //         __vModel__: 'field101'
+      //       },
+      //       {
+      //         __config__: {
+      //           layout: 'rowFormItem',
+      //           tagIcon: 'row',
+      //           label: '行容器',
+      //           layoutTree: true,
+      //           children: [
+      //             {
+      //               __config__: {
+      //                 label: '评分',
+      //                 tag: 'el-rate',
+      //                 tagIcon: 'rate',
+      //                 defaultValue: 0,
+      //                 span: 24,
+      //                 showLabel: true,
+      //                 labelWidth: null,
+      //                 layout: 'colFormItem',
+      //                 required: true,
+      //                 regList: [],
+      //                 changeTag: true,
+      //                 document: 'https://element.eleme.cn/#/zh-CN/component/rate',
+      //                 formId: 102,
+      //                 renderKey: 1586839671259
+      //               },
+      //               style: {},
+      //               max: 5,
+      //               'allow-half': false,
+      //               'show-text': false,
+      //               'show-score': false,
+      //               disabled: false,
+      //               __vModel__: 'field102'
+      //             }
+      //           ],
+      //           document: 'https://element.eleme.cn/#/zh-CN/component/layout',
+      //           formId: 101,
+      //           span: 24,
+      //           renderKey: 1586839668999,
+      //           componentName: 'row101',
+      //           gutter: 15
+      //         },
+      //         type: 'default',
+      //         justify: 'start',
+      //         align: 'top'
+      //       },
+      //       {
+      //         __config__: {
+      //           label: '按钮',
+      //           showLabel: true,
+      //           changeTag: true,
+      //           labelWidth: null,
+      //           tag: 'el-button',
+      //           tagIcon: 'button',
+      //           span: 24,
+      //           layout: 'colFormItem',
+      //           document: 'https://element.eleme.cn/#/zh-CN/component/button',
+      //           renderKey: 1594288459289
+      //         },
+      //         __slot__: {
+      //           default: '测试按钮1'
+      //         },
+      //         type: 'primary',
+      //         icon: 'el-icon-search',
+      //         round: false,
+      //         size: 'medium',
+      //         plain: false,
+      //         circle: false,
+      //         disabled: false,
+      //         on: {
+      //           click: 'clickTestButton1'
+      //         }
+      //       }
+      //     ],
+      //     __methods__: {
+      //       clickTestButton1() {
+      //         console.log(
+      //           `%c【测试按钮1】点击事件里可以访问当前表单:
+      //           1) formModel='formData', 所以this.formData可以拿到当前表单的model
+      //           2) formRef='elForm', 所以this.$refs.elForm可以拿到当前表单的ref(vue组件)
+      //         `,
+      //           'color:#409EFF;font-size: 15px'
+      //         )
+      //         console.log('表单的Model:', this.formData)
+      //         console.log('表单的ref:', this.$refs.elForm)
+      //       }
+      //     },
+      //     formRef: 'elForm',
+      //     formModel: 'formData',
+      //     size: 'small',
+      //     labelPosition: 'right',
+      //     labelWidth: 100,
+      //     formRules: 'rules',
+      //     gutter: 15,
+      //     disabled: false,
+      //     span: 24,
+      //     formBtns: true,
+      //     unFocusedComponentBorder: false
+      //   }
       });
     },
     decodeFields(fields) {

+ 3 - 3
yudao-admin-ui/src/views/tool/build/FormDrawer.vue

@@ -81,9 +81,9 @@ import ClipboardJS from 'clipboard'
 import { saveAs } from 'file-saver'
 import {
   makeUpHtml, vueTemplate, vueScript, cssStyle
-} from '@/utils/generator/html'
-import { makeUpJs } from '@/utils/generator/js'
-import { makeUpCss } from '@/utils/generator/css'
+} from '@/components/generator/html'
+import { makeUpJs } from '@/components/generator/js'
+import { makeUpCss } from '@/components/generator/css'
 import { exportDefault, beautifierConf, titleCase } from '@/utils/index'
 import ResourceDialog from './ResourceDialog'
 import loadMonaco from '@/utils/loadMonaco'

+ 1 - 1
yudao-admin-ui/src/views/tool/build/IconsDialog.vue

@@ -34,7 +34,7 @@
   </div>
 </template>
 <script>
-import iconList from '@/utils/generator/icon.json'
+import iconList from '@/utils/icon.json'
 
 const originList = iconList.map(name => `el-icon-${name}`)
 

+ 1 - 1
yudao-admin-ui/src/views/tool/build/RightPanel.vue

@@ -655,7 +655,7 @@ import { isNumberStr } from '@/utils/index'
 import IconsDialog from './IconsDialog'
 import {
   inputComponents, selectComponents, layoutComponents
-} from '@/utils/generator/config'
+} from '@/components/generator/config'
 import { saveFormConf } from '@/utils/db'
 
 const dateTimeFormat = {

+ 1 - 1
yudao-admin-ui/src/views/tool/build/index.vue

@@ -131,7 +131,7 @@ import JsonDrawer from './JsonDrawer'
 import RightPanel from './RightPanel'
 import {
   inputComponents, selectComponents, layoutComponents, formConf
-} from '@/utils/generator/config'
+} from '@/components/generator/config'
 import {
   exportDefault, beautifierConf, isNumberStr, titleCase, deepClone, isObjectObject
 } from '@/utils/index'