|
|
@@ -1,6 +1,6 @@ |
|
|
|
<template> |
|
|
|
<el-dialog class="super-flexible-dialog" :title="isDetail ? title.detail : !dataForm.id ? title.add : title.edit" :visible.sync="visible" @close="handleClose"> |
|
|
|
<el-form :model="dataForm" :rules="dataFormRules"> |
|
|
|
<el-form ref="dataForm" :model="dataForm" :rules="dataFormRules"> |
|
|
|
<!-- 如果需要更精细一点的布局,可以根据配置项实现地再复杂一点,但此处暂时全部采用一行两列布局 --> |
|
|
|
<el-row v-for="n in rows" :key="n" :gutter="20"> |
|
|
|
<el-col v-for="c in COLUMN_PER_ROW" :key="`${n}+'col'+${c}`" :span="24 / COLUMN_PER_ROW"> |
|
|
@@ -44,10 +44,12 @@ |
|
|
|
</el-form> |
|
|
|
|
|
|
|
<span slot="footer" class="dialog-footer"> |
|
|
|
<el-button v-for="(operate, index) in configs.operations" :key="`operate-${index}`" :type="btnType[operate.name]" @click="handleClick(operate)"> |
|
|
|
<template v-for="(operate, index) in configs.operations"> |
|
|
|
<!-- {{ operate.name | btnNameFilter }} --> |
|
|
|
{{ btnName[operate.name] }} |
|
|
|
</el-button> |
|
|
|
<el-button v-if="operate.permission ? $hasPermission(operate.permission) : true" :key="`operate-${index}`" :type="btnType[operate.name]" @click="handleClick(operate)">{{ |
|
|
|
btnName[operate.name] |
|
|
|
}}</el-button> |
|
|
|
</template> |
|
|
|
</span> |
|
|
|
</el-dialog> |
|
|
|
</template> |
|
|
@@ -87,7 +89,7 @@ export default { |
|
|
|
* type: 'dialog' | 'drawer' | 'page' |
|
|
|
* fields: Array<string|object> |
|
|
|
* - fields.object: { name, type: 'number'|'textarea'|'select'|'date'|.., required: boolean, validator: boolean(是否需要验证), [options]: any[], api: string(自动获取数据的接口,一般为getcode接口)} |
|
|
|
* operations: Array[object], 操作名和对应的接口地址 |
|
|
|
* operations: Array[object], 操作名和对应的接口地址,还有permission(如,sys:dict:update) |
|
|
|
*/ |
|
|
|
type: Object, |
|
|
|
default: () => ({}) // 此处省去类型检查,使用者自行注意就好 |
|
|
@@ -265,7 +267,7 @@ export default { |
|
|
|
method: btn.name === 'save' ? 'POST' : 'PUT', |
|
|
|
data: this.dataForm |
|
|
|
}).then(({ data: res }) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
if (res && res.code === 0) { |
|
|
|
this.$message({ |
|
|
|
message: btn.name === 'save' ? '添加成功!' : '更新成功!', |
|
|
|
type: 'success', |
|
|
|