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

修改组件部分设置

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