Commit 5ca77c4e authored by 毛线's avatar 毛线

修改组件部分设置

parent f7c2406d
......@@ -4,9 +4,9 @@
<slot v-if="item.type == 'slot'" :name="item.slotName" :data="item" :index="index"/>
<el-button
v-else
:type="item.attr.type"
:plain="item.attr.plain"
:icon="item.attr.icon"
:type="item.btnType"
:plain="item.plain"
:icon="item.icon"
:size="size"
:disabled="init().disabled(item)"
@click="handler().clickButton(item)"
......@@ -64,7 +64,7 @@ export default {
methods: {
init() {
return {
// button: ({ type = 'btn', label = '', hasPermi = [''], attr = '' }) => {
// button: ({ type = 'btn', label = '', hasPermi = [''], }) => {
// return {
// }
......@@ -78,7 +78,6 @@ export default {
// 初始化默认按钮相关参数
button: (button) => {
const { type } = button
let attr = {}
switch(type) {
case 'add': // 添加按钮
button.label = button.label ?? '新增'
......@@ -87,11 +86,9 @@ export default {
this.$emit('on-create')
})
attr = button.attr ?? {}
attr.type = attr.type ?? 'primary'
attr.plain = attr.plain ?? true
attr.icon = attr.icon ?? 'el-icon-plus'
button.attr = { ...attr }
button.btnType = button.btnType ?? 'primary'
button.plain = button.plain ?? true
button.icon = button.icon ?? 'el-icon-plus'
break
case 'edit': // 编辑按钮
button.label = button.label ?? '修改'
......@@ -101,11 +98,9 @@ export default {
this.$emit('on-update')
})
attr = button.attr ?? {}
attr.type = attr.type ?? 'success'
attr.plain = attr.plain ?? true
attr.icon = attr.icon ?? 'el-icon-edit'
button.attr = { ...attr }
button.btnType = button.btnType ?? 'success'
button.plain = button.plain ?? true
button.icon = button.icon ?? 'el-icon-edit'
break
case 'delete': // 删除按钮
button.label = button.label ?? '删除'
......@@ -115,11 +110,9 @@ export default {
this.$emit('on-delete')
})
attr = button.attr ?? {}
attr.type = attr.type ?? 'danger'
attr.plain = attr.plain ?? true
attr.icon = attr.icon ?? 'el-icon-delete'
button.attr = { ...attr }
button.btnType = button.btnType ?? 'danger'
button.plain = button.plain ?? true
button.icon = button.icon ?? 'el-icon-delete'
break
case 'export': // 导出按钮
button.label = button.label ?? '导出'
......@@ -128,22 +121,18 @@ export default {
this.$emit('on-export')
})
attr = button.attr ?? {}
attr.type = attr.type ?? 'warning'
attr.plain = attr.plain ?? true
attr.icon = attr.icon ?? 'el-icon-download'
button.attr = { ...attr }
button.btnType = button.btnType ?? 'warning'
button.plain = button.plain ?? true
button.icon = button.icon ?? 'el-icon-download'
break
default:
button.type = button.type ?? ''
button.label = button.label ?? ''
button.hasPermi = button.hasPermi ?? ['']
attr = button.attr ?? {}
attr.type = attr.type ?? 'primary'
attr.plain = attr.plain ?? true
attr.icon = attr.icon ?? ''
button.attr = { ...attr }
button.btnType = button.btnType ?? 'primary'
button.plain = button.plain ?? true
button.icon = button.icon ?? ''
break
}
return button
......
......@@ -13,6 +13,16 @@
>
<el-option v-for="(item, index) in item.options" :key="index" :value="item.value" :label="item.label" />
</el-select>
<el-time-select
v-else-if="item.type === 'time'"
v-model="params[item.field]"
:picker-options="item.pickerOptions"
:placeholder="item.placeholder"/>
<el-date-picker
v-else-if="item.type === 'data'"
v-model="params[item.field]"
type="date"
:placeholder="item.placeholder"/>
<el-input
v-else
v-model="params[item.field]"
......
......@@ -199,7 +199,7 @@ export default {
label: '', // 标题
field: '', // 字段名称
value: '', // 默认值
type: '', // 类型,input,select,cascader,date,datetimerange,slot
type: '', // 类型,input,select,cascader,date,time,slot
slotName: '', // 插槽名称,若tpe为slot,需要设置slotName。
placeholder: '请输入...', // 提示
multiple: false, // type为select时,是否多选
......@@ -215,12 +215,10 @@ export default {
slotName: '', // 自定义插槽名称,type为slot时必须设置此内容
label: '新增', // 按钮文字
disabledFlag: '', // 禁用类型,可选值为multiple、single、空字符串,若为multiple:不选择任何table内容时禁用,若为single:非单选时禁用,若为其他:任何情况下不禁用
btnType: 'primary',
plain: false,
icon: 'el-icon-plus',
click: () => {}, // 自定义回调函数,类型为add,edit,delete,export,这四个类型有自带的回调函数,若设置此参数,回调函数会被重写
attr: { // 按钮属性,目前可以设置type,plain,icon,内容参考element-ui文档
type: 'primary ',
plain: false,
icon: 'el-icon-plus',
},
},
],
// 表单相关配置
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment