0.0.4 • Published 12 months ago

@lxing-ui/isp-platform v0.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
12 months ago

该组件内部组件依赖于lxing-ui组件库,所以使用该组件务必引入lxing-ui

npm i lxing-ui

import lxingUI form 'lxing-ui'

Vue.use(lxingUI)

Getting Started

lxing-ui Document

isp-platform 安装

npm i @lxing-ui/isp-platform

效果图

npm.io

使用

import Ispplatform from '@lxing-ui/isp-platform'

// 1、全局引用
Vue.use(Ispplatform)
    
// 组件使用
<template>
    <div>
      <lx-isp-plateform></lx-isp-plateform>
    </div>
</template>

    
// 2、或者 局部引用
<template>
    <div>
      <isp-plateform></isp-plateform>
    </div>
</template>

export default {
  components: {
    Ispplatform
  }
}

attrs

参数说明数据类型可选值默认
auto-max-height是否自动设置高度,自动设置组件的高度为组件顶部值窗口底部的高度值Booleantrue/falsetrue
subtract-height自动设置高度后减去的值Number-0
menu-data左侧菜单的数据Array-[]
config-form-components配置表单项,点击模块的时候,模块可用的表单项Array-[]
multi-platform是否展示多平台规格,PC、H5、PadBooleantrue/falsetrue

attrs: menu-data 配置解析

参数说明数据类型可选值默认
label类型标题String-
components可选模块选项Array-

menu-data: components 模块配置解析

参数是否必须说明数据类型可选值默认
componentName模块唯一标识String-
label模块名称String-
moduleData模块的配置数据Object{}
attrList模块的表单Array[]

menu-data示例

const menuData = [{
  label: '容器',
  components: [
    {
      componentName: 'IconBtnList',
      label: '按钮列表',
      moduleData: {
        list: [
          {label: '', url: ''}
        ]
      },
      attrList: [
        {
          label: 'API地址',
          componentName: 'input',
          filed: 'url'
        },
        {
          label: '选项设置',
          filed: 'list',
          componentName: 'setOptions',
        }
      ]
    }]
}]

components: attrList 配置解析

参数是否必须说明数据类型可选值默认
label模块唯一标识String-
filedmoduleData的字段名String-
componentName对应表单项的组件标识String-

methods

方法名说明传参可选值默认
initModule初始化模块,可用于详情回显Array<getModels获取的数据结构>
getModules获取已选的模块数据,包括模块的配置数据-
addModule添加模块Object{ componentName: component(VNode) }]

Module Props

方法名说明传参
config整个module的配置项-
valuemoduleData中对应的值-
filed字段名称-

画布模块实例

Title 标题 npm.io

1、画布的模块并不是写死的,需要开发者自己设计开发,按照v-model的双向绑定的方式来开发组件即可,也就是说,组件需要 props.value 来接收数据。
2、画布组件会获取this.$emit("input", argument)来更新moduleData

模块添加方式

<template>
  <lx-isp-platform ref="lxispplatform"></lx-isp-platform>
</template>      


<script>
import Modules from './modules'
export default {
  data () {
    
  },
  methods: {
    setModule () {
      this.$refs.lxispplatform.initModule(Modules)
    }
  }
}
</script>

Modules实例

<template>
  <div class="title-wrap" :style="formData">
    <div v-show="formData.showLine" class="line"></div>
      <div class="title-text">{{ formData.text || '标题' }}</div>
    <div v-show="formData.showLine" class="line"></div>
  </div>
</template>

<script>
export default {
  name: "index",
  components: {},
  props: {
    value: {
      type: Object,
      default () {
        return {}
      }
    }
  },
  data() {
    return {
      formData: {
        text: '标题',
        textAlign: 'center',
        fontSize: '18px',
        showLine: true
      }
    }
  },
  watch: {
    value: {
      handler (val) {
        const { text, textAlign, fontSize } = val
        this.formData.text = text || '标题'
        this.formData.textAlign = textAlign || 'center'
        this.formData.fontSize = fontSize ? fontSize + 'px' : '18px'
        this.formData.showLine = val.showLine
      },
      deep: true,
      immediate: true
    }
  },
  methods: {},
  created() {
  },
  mounted() {
  }
}
</script>

<style scoped>
.title-wrap {
  padding: 8px 8px 16px;
}
.title-text {
  display: inline-block;
}
.line {
  width: 50px;
  height: 2px;
  background-color: rgba(151, 151, 151, 0.6);
  display: inline-block;
  vertical-align: 5px;
  margin: 0 15px;
}
</style>

右侧菜单项配置

{
          componentName: 'title',
          label: '标题',
          moduleData: {
            showLine: true
          },
          attrList: [
            { label: '文本内容', componentName: 'input', filed: 'text' },
            { label: '文字大小', componentName: 'numberInput', filed: 'fontSize' },
            { label: '位置', componentName: 'radio', filed: 'textAlign',
              options: [
                { label: '左', value: 'left' },
                { label: '中', value: 'center' },
                { label: '右', value: 'right' }
              ]
            },
            { label: '显示线条', componentName: 'switch', filed: 'showLine'}
          ]
}

表单项实例

1、表单并不是本组件写死的,而是由开发者自己决定导入什么样的组件作为表单项。
2、导入了表单项之后,才可以在 menu-data 中的 attrsList 中指定对应的表单项

ips-platform组件会给表单项组件传入默认props

attr Props

方法名说明传参
valuemoduleData中对应的值-
filed字段名称-
data菜单项的配置-
config整个菜单大类的配置-

导入方式

<template>
  <lx-isp-platform :config-form-components="components"></lx-isp-platform>
</template>      


<script>
import Components from './attrComponents'
export default {
  data () {
    components: Components || []
  }
}
</script>

Input 输入框

<template>
  <div>
    <el-input v-model="modelValue" @input="inputChange"></el-input>
  </div>
</template>

<script>
export default {
  name: "index",
  components: {},
  props: ['value'],
  data() {
    return {
      modelValue: ''
    }
  },
  methods: {
    inputChange (val) {
      this.modelValue = val
      this.$emit('input', val)
    }
  },
  created() {
  },
  mounted() {
    this.modelValue = this.value
  }
}
</script>

<style scoped>

</style>
0.0.4

12 months ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago