update dialog

This commit is contained in:
g7hoo 2022-08-10 16:28:39 +08:00
parent bc08dffda2
commit 174e5efae5
4 changed files with 37 additions and 12 deletions

6
package-lock.json generated
View File

@ -2603,6 +2603,12 @@
"resolved": "https://registry.npm.taobao.org/@types/json-schema/download/@types/json-schema-7.0.5.tgz", "resolved": "https://registry.npm.taobao.org/@types/json-schema/download/@types/json-schema-7.0.5.tgz",
"integrity": "sha1-3M5EMOZLRDuolF8CkPtWStW6xt0=" "integrity": "sha1-3M5EMOZLRDuolF8CkPtWStW6xt0="
}, },
"@types/lodash": {
"version": "4.14.182",
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.182.tgz",
"integrity": "sha512-/THyiqyQAP9AfARo4pF+aCGcyiQ94tX/Is2I7HofNRqoYLgN1PBoOWu2/zTA5zMxzP5EFutMtWtGAFRKUe961Q==",
"dev": true
},
"@types/minimatch": { "@types/minimatch": {
"version": "3.0.3", "version": "3.0.3",
"resolved": "https://registry.npm.taobao.org/@types/minimatch/download/@types/minimatch-3.0.3.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fminimatch%2Fdownload%2F%40types%2Fminimatch-3.0.3.tgz", "resolved": "https://registry.npm.taobao.org/@types/minimatch/download/@types/minimatch-3.0.3.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fminimatch%2Fdownload%2F%40types%2Fminimatch-3.0.3.tgz",

View File

@ -32,6 +32,7 @@
"vuex": "^3.5.1" "vuex": "^3.5.1"
}, },
"devDependencies": { "devDependencies": {
"@types/lodash": "^4.14.182",
"@vue/cli-plugin-babel": "^4.4.6", "@vue/cli-plugin-babel": "^4.4.6",
"@vue/cli-service": "^4.4.6", "@vue/cli-service": "^4.4.6",
"element-theme-chalk": "^2.15.7", "element-theme-chalk": "^2.15.7",

View File

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

View File

@ -149,9 +149,10 @@ const addOrUpdateConfigs = {
} }
], ],
operations: [ operations: [
{ name: 'reset', url: true }, // { name: 'reset', url: true },
{ name: 'save', url: '/monitoring/product', permission: '' }, { name: 'cancel', url: true, showAlways: true },
{ name: 'update', url: '/monitoring/product', permission: '' } { name: 'save', url: '/monitoring/product', permission: '', showOnEdit: false },
{ name: 'update', url: '/monitoring/product', permission: '', showOnEdit: true }
], ],
subtable: { subtable: {
// for i18n // for i18n