|
|
@@ -44,7 +44,7 @@ |
|
|
|
</template> |
|
|
|
</el-form> |
|
|
|
|
|
|
|
<template v-if="configs.subtable"> |
|
|
|
<template v-if="dataForm.id && configs.subtable"> |
|
|
|
<h3>{{ configs.subtable.title }}</h3> |
|
|
|
<component |
|
|
|
key="sub-table" |
|
|
@@ -60,15 +60,21 @@ |
|
|
|
<span slot="footer" class="dialog-footer"> |
|
|
|
<template v-for="(operate, index) in configs.operations"> |
|
|
|
<!-- {{ operate.name | btnNameFilter }} --> |
|
|
|
<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> |
|
|
|
<el-button |
|
|
|
v-if="(operate.showAlways || ((dataForm.id && operate.showOnEdit) || (!dataForm.id && !operate.showOnEdit)) && (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> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { pick } from 'lodash/object' |
|
|
|
|
|
|
|
// 标题 for i18n |
|
|
|
const title = { |
|
|
|
detail: '详情', |
|
|
@@ -81,6 +87,7 @@ const btnType = { |
|
|
|
save: 'success', |
|
|
|
update: 'primary', |
|
|
|
reset: 'text' |
|
|
|
// cancel: 'text' |
|
|
|
// add more... |
|
|
|
} |
|
|
|
|
|
|
@@ -88,7 +95,8 @@ const btnName = { |
|
|
|
// for i18n |
|
|
|
save: '保存', |
|
|
|
update: '更新', |
|
|
|
reset: '重置' |
|
|
|
reset: '重置', |
|
|
|
cancel: '取消' |
|
|
|
// add more... |
|
|
|
} |
|
|
|
|
|
|
@@ -283,17 +291,25 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
init(id) { |
|
|
|
this.dataForm.id = id || null |
|
|
|
this.visible = true |
|
|
|
this.$nextTick(() => { |
|
|
|
this.$refs['dataForm'].resetFields() |
|
|
|
this.dataForm.id = id || null |
|
|
|
console.log('dataform ===> ', this.dataForm) |
|
|
|
|
|
|
|
if (this.dataForm.id) { |
|
|
|
console.log('here...') |
|
|
|
this.$http({ |
|
|
|
url: this.$http.adornUrl(`${this.infoUrl}/${this.dataForm.id}`), |
|
|
|
url: this.$http.adornUrl(`${this.configs.infoUrl}/${this.dataForm.id}`), |
|
|
|
method: 'get' |
|
|
|
}).then(({ data: res }) => { |
|
|
|
if (res && res.code === 0) { |
|
|
|
this.dataForm = |
|
|
|
const dataFormKeys = Object.keys(this.dataForm) |
|
|
|
console.log('keys: ', dataFormKeys) |
|
|
|
console.log('resdata: ', res.data) |
|
|
|
console.log('pick: ', pick) |
|
|
|
console.log('after pick data: ', pick(res.data, dataFormKeys)) |
|
|
|
this.dataForm = pick(res.data, dataFormKeys) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
@@ -343,8 +359,9 @@ export default { |
|
|
|
this.dataForm[key] = null |
|
|
|
} |
|
|
|
} |
|
|
|
console.log('after reset: ', JSON.stringify(this.dataForm)) |
|
|
|
break |
|
|
|
case 'cancel': |
|
|
|
this.visible = false |
|
|
|
// add more.. |
|
|
|
} |
|
|
|
}, |
|
|
|