Skip to content

Zeal 组件 ​

提供便于列表操作的组件,均从 dynamicformdjx-vue2/elementUi 导入。示例使用 Vue 2.7 和 Element UI。

1. ElePopupModal ​

弹出对话框,通过 ref 的 toggle(flag?) 打开或关闭;省略参数时切换。

属性名说明类型默认值必填
title弹窗标题string—否
modalPropsElement UI Dialog 属性object{}否
to挂载容器string 或 HTMLElement—否
showClose显示关闭按钮booleantrue否
closeOnMask点击遮罩关闭booleantrue否
width对话框宽度stringmin(1080px,90%)否
onCancel / onSubmit底部按钮回调,返回 false 保持打开,支持 Promisefunction返回 true否
footerTxt取消、提交文案string[]['Cancel', 'Submit']否

Slots ​

default 为内容,title 为标题,footer 替换底部按钮。onCancel 针对底部取消按钮;遮罩和右上角关闭由 Dialog 更新可见状态,不调用该回调。

示例 ​

Details
vue
<script>
import { ElePopupModal } from 'dynamicformdjx-vue2/elementUi'
export default {
  components: { ElePopupModal },
  data () { return { keepOpen: false, result: '' } },
  methods: {
    async submit () {
      this.result = this.keepOpen ? '返回 false,保持打开' : '提交成功'
      return !this.keepOpen
    }
  }
}
</script>

<template>
  <section style="padding: 16px">
    <el-button @click="$refs.modal.toggle(true)">打开弹窗</el-button>
    <ElePopupModal ref="modal" title="示例弹窗" :on-submit="submit" :footer-txt="['取消', '提交']">
      <el-checkbox v-model="keepOpen">提交时返回 false,保持打开</el-checkbox>
    </ElePopupModal>
    <pre aria-live="polite">{{ result }}</pre>
  </section>
</template>

2. EleZealCard ​

用于查询区、操作区、表格和分页的卡片容器,自动计算表格可用高度。

属性名说明类型默认值必填
title标题string—否
zealHeight外部高度string100vh否
outPadding上下预留间距,每边扣除此值number20否
checkWindowSize移动端阈值、resize 防抖毫秒数number[][756, 500]否
observeDelay测量防抖毫秒数number100否
searchBtnTxt默认搜索按钮文案string[]['Reset', 'Search']否

Slots ​

header、searchForm、searchBtn、controlBtn、toolBtn、footer、rest 提供 { isMobile, width, height },default 额外提供 tableHeight。header 替换默认标题与查询区;rest 适合放弹窗。默认查询按钮没有业务事件,请使用 searchBtn 插槽绑定事件或接入 EleZealTableSearch。

示例 ​

Details
vue
<script>
import { EleZealCard } from 'dynamicformdjx-vue2/elementUi'
export default { components: { EleZealCard } }
</script>

<template>
  <section style="padding: 16px">
    <EleZealCard title="列表卡片" zeal-height="360px" :out-padding="0">
      <template slot="controlBtn"><el-button size="small">新增</el-button></template>
      <template slot-scope="scope">
        <p>isMobile: {{ scope.isMobile }},tableHeight: {{ scope.tableHeight }}</p>
      </template>
      <template slot="footer">底部分页区</template>
    </EleZealCard>
  </section>
</template>

3. EleZealTableSearch ​

桌面端显示栅格查询表单,移动端可切换为顶部抽屉。

属性名说明类型默认值必填
title / drawerTitle标题 / 抽屉标题string—否
searchItems查询字段DyFormItem[][]否
isMobile移动端模式booleanfalse否
mobileDrawer移动端启用抽屉booleantrue否
size抽屉大小number 或 string240否
searchFormMaxHeight桌面查询区最大高度string200px否
drawerOpenTxt抽屉按钮文字stringSearch Drawer否
searchBtnTxt重置和查询文案string[]['Reset', 'Search']否
copyDefault挂载时保存字段初值,用于重置booleanfalse否
closeDrawerAutofalse 时切换到桌面自动关闭抽屉booleanfalse否
formSize桌面表单尺寸,建议传 small / ministringdefault否

Emits / Ref ​

@onSearch 接收查询参数;@onReset 在重置后触发。copyDefault=false 时重置为 null。实例方法有 getParams()、onSearch()、onReset()、toggleDrawer(flag?)。

Slots ​

title 自定义标题,drawerBtn 提供 { openDrawer },searchBtn 提供 { onSearch, onReset }。

示例 ​

Details
vue
<script>
import { EleZealTableSearch, useDecorateForm } from 'dynamicformdjx-vue2/elementUi'
export default {
  components: { EleZealTableSearch },
  data () {
    return {
      mobile: false, result: '',
      items: useDecorateForm([{ key: 'name', label: '姓名', value: '', span: 12 }])
    }
  },
  methods: { search (values) { this.result = JSON.stringify(values) } }
}
</script>

<template>
  <section style="padding: 16px">
    <el-switch v-model="mobile" active-text="抽屉模式" />
    <EleZealTableSearch title="搜索" :search-items="items" :is-mobile="mobile"
                        form-size="small" :search-btn-txt="['重置', '查询']" drawer-open-txt="打开查询"
                        @onSearch="search" @onReset="result = '已重置'" />
    <pre aria-live="polite">{{ result }}</pre>
  </section>
</template>

4. EleZealTablePaginationControl ​

连接 usePagination() 与 Element UI Pagination。

属性名说明类型默认值必填
pagination分页对象ZealPagination—是
pageConfig覆盖 Pagination 属性object{}否
isMobile无默认插槽时移除 sizes、jumperbooleanfalse否

页码变化时先更新 pageNo,再调用 pagination.onChange();每页条数变化时先将 pageNo 设为 1、更新 pageSize,再调用 onPageSizeChange()。default 插槽传给 Pagination。

示例 ​

Details
vue
<script>
import { EleZealTablePaginationControl, usePagination } from 'dynamicformdjx-vue2/elementUi'
export default {
  components: { EleZealTablePaginationControl },
  data () {
    return {
      mobile: false, result: '',
      pagination: usePagination(undefined, { total: 55, pageSize: 5, pageSizes: [5, 10, 20] })
    }
  },
  created () {
    this.pagination.onChange = () => { this.result = '页码:' + this.pagination.pageNo }
    this.pagination.onPageSizeChange = () => {
      this.result = '每页:' + this.pagination.pageSize + ',页码:' + this.pagination.pageNo
    }
  }
}
</script>

<template>
  <section style="padding: 16px">
    <el-switch v-model="mobile" active-text="移动端布局" />
    <EleZealTablePaginationControl :pagination="pagination" :is-mobile="mobile" />
    <pre aria-live="polite">{{ result }}</pre>
  </section>
</template>

5. EleZealTable ​

根据 columns 生成 Element UI TableColumn。

属性名说明类型默认值必填
data数据object[][]否
columns列配置ZealColumn[][]否
loading加载状态booleanfalse否
maxHeight最大高度number 或 string—否
columnAlign默认对齐方式left / center / right—否
stripe / border斑马纹 / 边框booleantrue / false否
tableConfigTable 属性object{}否

Slots / Events ​

单元格优先级为 column.render2(row, index)、具名插槽、row[prop]。显式 slot 指定插槽名,否则使用 cell-字段名。单元格插槽提供 { row, $index }。支持 empty、append,事件如 selection-change 透传到 Table。

示例 ​

Details
vue
<script>
import { EleZealTable } from 'dynamicformdjx-vue2/elementUi'
export default {
  components: { EleZealTable },
  data () {
    return {
      result: '', rows: [{ id: 1, name: '张三' }, { id: 2, name: '李四' }],
      columns: [{ prop: 'id', label: '编号' }, { prop: 'name', label: '姓名' },
        { label: '操作', slot: 'actions' }]
    }
  }
}
</script>

<template>
  <section style="padding: 16px">
    <EleZealTable :data="rows" :columns="columns">
      <template slot="cell-name" slot-scope="cell"><el-tag>{{ cell.row.name }}</el-tag></template>
      <template slot="actions" slot-scope="cell">
        <el-button size="small" @click="result = cell.row.name">查看</el-button>
      </template>
    </EleZealTable>
    <pre aria-live="polite">{{ result }}</pre>
  </section>
</template>

6. EleZealTableBtnControl ​

桌面显示按钮组,移动端显示下拉菜单。

属性名说明类型默认值必填
btnItems按钮配置,key 必填TableBtnType[][]否
isMobile下拉模式booleanfalse否
size按钮尺寸stringsmall否
dropDownPropsDropdown 属性object{}否
dropDownText下拉入口文字stringcontrols否

选择按钮时先调用按钮自身的 onSelect(key),然后触发 @onSelect。text 插槽替换下拉入口。disabled 同时作用于按钮和菜单项。

示例 ​

Details
vue
<script>
import { EleZealTableBtnControl } from 'dynamicformdjx-vue2/elementUi'
export default {
  components: { EleZealTableBtnControl },
  data () {
    return { mobile: false, result: '', buttons: [
      { key: 'edit', title: '编辑' }, { key: 'delete', title: '删除', type: 'danger' }
    ] }
  }
}
</script>

<template>
  <section style="padding: 16px">
    <el-switch v-model="mobile" active-text="下拉菜单" />
    <EleZealTableBtnControl :btn-items="buttons" :is-mobile="mobile" drop-down-text="操作"
                            @onSelect="result = $event" />
    <pre aria-live="polite">{{ result }}</pre>
  </section>
</template>