hm-ui

内置了常用组件、过滤器、工具函数。源码

组件-步骤条

引导用户按照流程完成任务的导航条

代码演示

点击预览

  1. <hm-steps :active="currentStep" :steps="steps" :showAction="showStepAction" @change="onStepChange">
  2. <div class="steps-slot-wrap">
  3. <div class="step-slot" v-if="currentStep === 0">操作 {{steps[currentStep].title}} Step</div>
  4. <div class="step-slot" v-if="currentStep === 1">操作 {{steps[currentStep].title}} Step</div>
  5. <div class="step-slot" v-if="currentStep === 2">操作 {{steps[currentStep].title}} Step</div>
  6. <div class="step-slot" v-if="currentStep === 3">操作 {{steps[currentStep].title}} Step</div>
  7. <div class="step-slot" v-if="currentStep === 4">操作完成,页面路由跳走 或 自定义操作成功页</div>
  8. </div>
  9. </hm-steps>
  1. export default {
  2. data() {
  3. return {
  4. currentStep: 0,
  5. showStepAction: true,
  6. steps: [
  7. {
  8. title: 'First',
  9. description: 'First-description',
  10. },
  11. {
  12. title: 'Second',
  13. description: 'Second-description',
  14. },
  15. {
  16. title: 'Thrid',
  17. description: 'Thrid-description',
  18. },
  19. {
  20. title: 'Last',
  21. description: 'Last-description',
  22. },
  23. ],
  24. // hm-steps end
  25. }
  26. },
  27. methods: {
  28. onStepChange(param) {
  29. this.currentStep = param.active
  30. console.info('onStepChange', param)
  31. },
  32. },
  33. }

API

参数 说明 类型 默认值 可选值
labelPlacement 指定标签放置位置 String vertical horizontal,vertical
showAction 是否显示底部按钮(下一步、上一步) Boolean true true,false
current 指定当前步骤 Number 0 -
steps 步骤数据列表 Array [] [{title: ‘title’, description: ‘description’}]
title steps中title的字段名 String title -
description steps中description的字段名 String description -
doneTxt 最后一步完成的提示语 String - -

组件-select下拉框

实现目的:解决ant-design中的select下拉框在多数据情况下的卡顿问题
实现逻辑:根据用户输入关键字过滤数组中的数据

  1. <hm-select :props="{
  2. value: 'id',
  3. label: 'name'
  4. }"
  5. :data="data"
  6. placeholder="输入内容"
  7. :showArrow="true"
  8. mode="default"
  9. style="width: 250px;"
  10. v-decorator="['company', {
  11. initialValue: company,
  12. rules: [
  13. { required: true, message: '请输入内容' },
  14. ],
  15. }]"
  16. @change="change"></hm-select>
  1. export default {
  2. data() {
  3. return {
  4. data: [
  5. { id: 1, name: '张三' },
  6. { id: 2, name: '李四' },
  7. { id: 3, name: '王五' },
  8. { id: 4, name: '张五' },
  9. { id: 5, name: '张三丰' },
  10. { id: 6, name: '王大叔' },
  11. { id: 7, name: '王几分' },
  12. { id: 8, name: '王东五' }
  13. ],
  14. company: '',
  15. }
  16. },
  17. methods: {
  18. change(value) {
  19. console.log(value)
  20. },
  21. },
  22. }

API

参数 说明 类型 默认值 可选值
size 选择框大小 String default large,small
allowClear 是否可清除 Boolean true true,false
mode 选择模式 String default multiple
props 字段映射 Object {value: ‘id’, label: ‘name’} -
data 数据列表 Array [] -
showArrow 是否显示下拉箭头 Boolean true true,false
placeholder 选择框默认文案 String ‘请输入搜索关键字’ -

组件-费率

统一各个系统用到的费率表单

::: tip hm-rate里存在各种数据校验,所以这里我们要求结合form表单使用
费率类型包含三种:

  • NO_STEP 固定比例收费(实发金额)
  • PERSON_STEP_ONLY 不分月流水阶梯
  • BOTH_STEP 分月流水阶梯
    :::
  1. <a-form id="hmRate" :form="form" v-bind="formItemLayout" @submit="handleSubmit">
  2. <a-form-item label="姓名:">
  3. <a-input v-decorator="[
  4. 'username',
  5. { rules: [{ required: true, message: '请输入姓名' }] },
  6. ]"
  7. placeholder="请输入姓名"
  8. />
  9. </a-form-item>
  10. <hm-rate ref="hmRate"
  11. v-model="stepType"
  12. :rateList="initData"
  13. :formItemLayout="formItemLayout"></hm-rate>
  14. <a-form-item :wrapper-col="{ span: 20, offset: 4 }">
  15. <a-button type="primary" html-type="submit">提交</a-button>
  16. </a-form-item>
  17. </a-form>
  1. export default {
  2. data() {
  3. return {
  4. initData: [{
  5. key: 'level-0',
  6. leftVal: '0',
  7. rightVal: '',
  8. totalStepValWithRateDTOList: [
  9. {
  10. key: 'level-0-0',
  11. leftVal: '0',
  12. rightVal: '',
  13. rate: '',
  14. },
  15. ],
  16. }, {
  17. key: 'level-1',
  18. leftVal: '0',
  19. rightVal: '',
  20. totalStepValWithRateDTOList: [
  21. {
  22. key: 'level-1-0',
  23. leftVal: '0',
  24. rightVal: '',
  25. rate: '',
  26. },
  27. ],
  28. }],
  29. form: this.$form.createForm(this, { name: 'hmRate' }),
  30. // NO_STEP 固定比例收费(实发金额)
  31. // PERSON_STEP_ONLY 不分月流水阶梯
  32. // BOTH_STEP 分月流水阶梯
  33. stepType: 'NO_STEP',
  34. formItemLayout: {
  35. labelCol: { span: 4 },
  36. wrapperCol: { span: 20 },
  37. },
  38. }
  39. },
  40. methods: {
  41. handleSubmit(e) {
  42. e.preventDefault()
  43. this.form.validateFields((err, values) => {
  44. console.log(values)
  45. if (err) return
  46. // 获取费率数据
  47. console.log(this.$refs.hmRate.getData())
  48. })
  49. },
  50. },
  51. }

API

参数 说明 类型 默认值 可选值
rateList 初始数据 Array [] -
formItemLayout 布局 Object {labelCol: { span: 4 }, wrapperCol: { span: 20 }} -

组件-upload上传

统一的上传组件 支持多个图片上传/多选 多张图片上传只需传入按钮文本为数组

  1. <hm-upload :buttonText="['Upload']"></hm-select>
  1. #### API
  2. | 参数 | 说明 | 类型| 默认值 | 可选值 |
  3. |-----|:----------|:------|:------------|:--------|
  4. | buttonText | 按钮文案 | Array,String | - | - |
  5. | imageList | 图片数组 | Array | [] | - |
  6. | multiple | 支持多选 | Boolean | false | - |
  7. ## 过滤器
  8. 过滤器-描述
  9. #### 代码演示
  10. ```js

工具函数

工具函数-描述

代码演示

js